diff --git a/Godeps/LICENSES b/Godeps/LICENSES index 7a2f270670e..f4926428664 100644 --- a/Godeps/LICENSES +++ b/Godeps/LICENSES @@ -3932,402 +3932,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================================================ -================================================================================ -= vendor/github.com/d2g/dhcp4 licensed under: = - -Copyright (c) 2013 Skagerrak Software Limited. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Skagerrak Software Limited nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -= vendor/github.com/d2g/dhcp4/LICENSE 0187683301a45e8ea393bb2ffd7889c8 -================================================================================ - - -================================================================================ -= vendor/github.com/d2g/dhcp4client licensed under: = - -Mozilla Public License, version 2.0 - -1. Definitions - -1.1. “Contributor” - - means each individual or legal entity that creates, contributes to the - creation of, or owns Covered Software. - -1.2. “Contributor Version” - - means the combination of the Contributions of others (if any) used by a - Contributor and that particular Contributor’s Contribution. - -1.3. “Contribution” - - means Covered Software of a particular Contributor. - -1.4. “Covered Software” - - means Source Code Form to which the initial Contributor has attached the - notice in Exhibit A, the Executable Form of such Source Code Form, and - Modifications of such Source Code Form, in each case including portions - thereof. - -1.5. “Incompatible With Secondary Licenses” - means - - a. that the initial Contributor has attached the notice described in - Exhibit B to the Covered Software; or - - b. that the Covered Software was made available under the terms of version - 1.1 or earlier of the License, but not also under the terms of a - Secondary License. - -1.6. “Executable Form” - - means any form of the work other than Source Code Form. - -1.7. “Larger Work” - - means a work that combines Covered Software with other material, in a separate - file or files, that is not Covered Software. - -1.8. “License” - - means this document. - -1.9. “Licensable” - - means having the right to grant, to the maximum extent possible, whether at the - time of the initial grant or subsequently, any and all of the rights conveyed by - this License. - -1.10. “Modifications” - - means any of the following: - - a. any file in Source Code Form that results from an addition to, deletion - from, or modification of the contents of Covered Software; or - - b. any new file in Source Code Form that contains any Covered Software. - -1.11. “Patent Claims” of a Contributor - - means any patent claim(s), including without limitation, method, process, - and apparatus claims, in any patent Licensable by such Contributor that - would be infringed, but for the grant of the License, by the making, - using, selling, offering for sale, having made, import, or transfer of - either its Contributions or its Contributor Version. - -1.12. “Secondary License” - - means either the GNU General Public License, Version 2.0, the GNU Lesser - General Public License, Version 2.1, the GNU Affero General Public - License, Version 3.0, or any later versions of those licenses. - -1.13. “Source Code Form” - - means the form of the work preferred for making modifications. - -1.14. “You” (or “Your”) - - means an individual or a legal entity exercising rights under this - License. For legal entities, “You” includes any entity that controls, is - controlled by, or is under common control with You. For purposes of this - definition, “control” means (a) the power, direct or indirect, to cause - the direction or management of such entity, whether by contract or - otherwise, or (b) ownership of more than fifty percent (50%) of the - outstanding shares or beneficial ownership of such entity. - - -2. License Grants and Conditions - -2.1. Grants - - Each Contributor hereby grants You a world-wide, royalty-free, - non-exclusive license: - - a. under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or as - part of a Larger Work; and - - b. under Patent Claims of such Contributor to make, use, sell, offer for - sale, have made, import, and otherwise transfer either its Contributions - or its Contributor Version. - -2.2. Effective Date - - The licenses granted in Section 2.1 with respect to any Contribution become - effective for each Contribution on the date the Contributor first distributes - such Contribution. - -2.3. Limitations on Grant Scope - - The licenses granted in this Section 2 are the only rights granted under this - License. No additional rights or licenses will be implied from the distribution - or licensing of Covered Software under this License. Notwithstanding Section - 2.1(b) above, no patent license is granted by a Contributor: - - a. for any code that a Contributor has removed from Covered Software; or - - b. for infringements caused by: (i) Your and any other third party’s - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - - c. under Patent Claims infringed by Covered Software in the absence of its - Contributions. - - This License does not grant any rights in the trademarks, service marks, or - logos of any Contributor (except as may be necessary to comply with the - notice requirements in Section 3.4). - -2.4. Subsequent Licenses - - No Contributor makes additional grants as a result of Your choice to - distribute the Covered Software under a subsequent version of this License - (see Section 10.2) or under the terms of a Secondary License (if permitted - under the terms of Section 3.3). - -2.5. Representation - - Each Contributor represents that the Contributor believes its Contributions - are its original creation(s) or it has sufficient rights to grant the - rights to its Contributions conveyed by this License. - -2.6. Fair Use - - This License is not intended to limit any rights You have under applicable - copyright doctrines of fair use, fair dealing, or other equivalents. - -2.7. Conditions - - Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in - Section 2.1. - - -3. Responsibilities - -3.1. Distribution of Source Form - - All distribution of Covered Software in Source Code Form, including any - Modifications that You create or to which You contribute, must be under the - terms of this License. You must inform recipients that the Source Code Form - of the Covered Software is governed by the terms of this License, and how - they can obtain a copy of this License. You may not attempt to alter or - restrict the recipients’ rights in the Source Code Form. - -3.2. Distribution of Executable Form - - If You distribute Covered Software in Executable Form then: - - a. such Covered Software must also be made available in Source Code Form, - as described in Section 3.1, and You must inform recipients of the - Executable Form how they can obtain a copy of such Source Code Form by - reasonable means in a timely manner, at a charge no more than the cost - of distribution to the recipient; and - - b. You may distribute such Executable Form under the terms of this License, - or sublicense it under different terms, provided that the license for - the Executable Form does not attempt to limit or alter the recipients’ - rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - - You may create and distribute a Larger Work under terms of Your choice, - provided that You also comply with the requirements of this License for the - Covered Software. If the Larger Work is a combination of Covered Software - with a work governed by one or more Secondary Licenses, and the Covered - Software is not Incompatible With Secondary Licenses, this License permits - You to additionally distribute such Covered Software under the terms of - such Secondary License(s), so that the recipient of the Larger Work may, at - their option, further distribute the Covered Software under the terms of - either this License or such Secondary License(s). - -3.4. Notices - - You may not remove or alter the substance of any license notices (including - copyright notices, patent notices, disclaimers of warranty, or limitations - of liability) contained within the Source Code Form of the Covered - Software, except that You may alter any license notices to the extent - required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - - You may choose to offer, and to charge a fee for, warranty, support, - indemnity or liability obligations to one or more recipients of Covered - Software. However, You may do so only on Your own behalf, and not on behalf - of any Contributor. You must make it absolutely clear that any such - warranty, support, indemnity, or liability obligation is offered by You - alone, and You hereby agree to indemnify every Contributor for any - liability incurred by such Contributor as a result of warranty, support, - indemnity or liability terms You offer. You may include additional - disclaimers of warranty and limitations of liability specific to any - jurisdiction. - -4. Inability to Comply Due to Statute or Regulation - - If it is impossible for You to comply with any of the terms of this License - with respect to some or all of the Covered Software due to statute, judicial - order, or regulation then You must: (a) comply with the terms of this License - to the maximum extent possible; and (b) describe the limitations and the code - they affect. Such description must be placed in a text file included with all - distributions of the Covered Software under this License. Except to the - extent prohibited by statute or regulation, such description must be - sufficiently detailed for a recipient of ordinary skill to be able to - understand it. - -5. Termination - -5.1. The rights granted under this License will terminate automatically if You - fail to comply with any of its terms. However, if You become compliant, - then the rights granted under this License from a particular Contributor - are reinstated (a) provisionally, unless and until such Contributor - explicitly and finally terminates Your grants, and (b) on an ongoing basis, - if such Contributor fails to notify You of the non-compliance by some - reasonable means prior to 60 days after You have come back into compliance. - Moreover, Your grants from a particular Contributor are reinstated on an - ongoing basis if such Contributor notifies You of the non-compliance by - some reasonable means, this is the first time You have received notice of - non-compliance with this License from such Contributor, and You become - compliant prior to 30 days after Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent - infringement claim (excluding declaratory judgment actions, counter-claims, - and cross-claims) alleging that a Contributor Version directly or - indirectly infringes any patent, then the rights granted to You by any and - all Contributors for the Covered Software under Section 2.1 of this License - shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user - license agreements (excluding distributors and resellers) which have been - validly granted by You or Your distributors under this License prior to - termination shall survive termination. - -6. Disclaimer of Warranty - - Covered Software is provided under this License on an “as is” basis, without - warranty of any kind, either expressed, implied, or statutory, including, - without limitation, warranties that the Covered Software is free of defects, - merchantable, fit for a particular purpose or non-infringing. The entire - risk as to the quality and performance of the Covered Software is with You. - Should any Covered Software prove defective in any respect, You (not any - Contributor) assume the cost of any necessary servicing, repair, or - correction. This disclaimer of warranty constitutes an essential part of this - License. No use of any Covered Software is authorized under this License - except under this disclaimer. - -7. Limitation of Liability - - Under no circumstances and under no legal theory, whether tort (including - negligence), contract, or otherwise, shall any Contributor, or anyone who - distributes Covered Software as permitted above, be liable to You for any - direct, indirect, special, incidental, or consequential damages of any - character including, without limitation, damages for lost profits, loss of - goodwill, work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses, even if such party shall have been - informed of the possibility of such damages. This limitation of liability - shall not apply to liability for death or personal injury resulting from such - party’s negligence to the extent applicable law prohibits such limitation. - Some jurisdictions do not allow the exclusion or limitation of incidental or - consequential damages, so this exclusion and limitation may not apply to You. - -8. Litigation - - Any litigation relating to this License may be brought only in the courts of - a jurisdiction where the defendant maintains its principal place of business - and such litigation shall be governed by laws of that jurisdiction, without - reference to its conflict-of-law provisions. Nothing in this Section shall - prevent a party’s ability to bring cross-claims or counter-claims. - -9. Miscellaneous - - This License represents the complete agreement concerning the subject matter - hereof. If any provision of this License is held to be unenforceable, such - provision shall be reformed only to the extent necessary to make it - enforceable. Any law or regulation which provides that the language of a - contract shall be construed against the drafter shall not be used to construe - this License against a Contributor. - - -10. Versions of the License - -10.1. New Versions - - Mozilla Foundation is the license steward. Except as provided in Section - 10.3, no one other than the license steward has the right to modify or - publish new versions of this License. Each version will be given a - distinguishing version number. - -10.2. Effect of New Versions - - You may distribute the Covered Software under the terms of the version of - the License under which You originally received the Covered Software, or - under the terms of any subsequent version published by the license - steward. - -10.3. Modified Versions - - If you create software not governed by this License, and you want to - create a new license for such software, you may create and use a modified - version of this License if you rename the license and remove any - references to the name of the license steward (except to note that such - modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses - If You choose to distribute Source Code Form that is Incompatible With - Secondary Licenses under the terms of this version of the License, the - notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice - - This Source Code Form is subject to the - terms of the Mozilla Public License, v. - 2.0. If a copy of the MPL was not - distributed with this file, You can - obtain one at - http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular file, then -You may include the notice in a location (such as a LICENSE file in a relevant -directory) where a recipient would be likely to look for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - “Incompatible With Secondary Licenses” Notice - - This Source Code Form is “Incompatible - With Secondary Licenses”, as defined by - the Mozilla Public License, v. 2.0. - - -= vendor/github.com/d2g/dhcp4client/LICENSE b278a92d2c1509760384428817710378 -================================================================================ - - ================================================================================ = vendor/github.com/davecgh/go-spew licensed under: = @@ -18390,297 +17994,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI ================================================================================ -================================================================================ -= vendor/github.com/vmware/photon-controller-go-sdk licensed under: = - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - -"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. - -"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. - -"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. - -"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. - -"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. - -"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. - -"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). - -"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. - -"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." - -"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: -(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and -(b) You must cause any modified files to carry prominent notices stating that You changed the files; and -(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and -(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. - -You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - -To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied. - - See the License for the specific language governing permissions and - limitations under the License. - - - -= vendor/github.com/vmware/photon-controller-go-sdk/LICENSE 0de60303c844eac44e45012dac1987de -================================================================================ - - -================================================================================ -= vendor/github.com/xanzy/go-cloudstack licensed under: = - -Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -= vendor/github.com/xanzy/go-cloudstack/LICENSE 136e4f49dbf29942c572a3a8f6e88a77 -================================================================================ - - ================================================================================ = vendor/github.com/xiang90/probing licensed under: = diff --git a/cmd/kube-controller-manager/app/BUILD b/cmd/kube-controller-manager/app/BUILD index 6fdd483cedb..1158d2ed4ac 100644 --- a/cmd/kube-controller-manager/app/BUILD +++ b/cmd/kube-controller-manager/app/BUILD @@ -100,7 +100,6 @@ go_library( "//pkg/volume/iscsi:go_default_library", "//pkg/volume/local:go_default_library", "//pkg/volume/nfs:go_default_library", - "//pkg/volume/photon_pd:go_default_library", "//pkg/volume/portworx:go_default_library", "//pkg/volume/quobyte:go_default_library", "//pkg/volume/rbd:go_default_library", diff --git a/cmd/kube-controller-manager/app/plugins.go b/cmd/kube-controller-manager/app/plugins.go index 514c8fa94d7..bb587407990 100644 --- a/cmd/kube-controller-manager/app/plugins.go +++ b/cmd/kube-controller-manager/app/plugins.go @@ -45,7 +45,6 @@ import ( "k8s.io/kubernetes/pkg/volume/iscsi" "k8s.io/kubernetes/pkg/volume/local" "k8s.io/kubernetes/pkg/volume/nfs" - "k8s.io/kubernetes/pkg/volume/photon_pd" "k8s.io/kubernetes/pkg/volume/portworx" "k8s.io/kubernetes/pkg/volume/quobyte" "k8s.io/kubernetes/pkg/volume/rbd" @@ -73,7 +72,6 @@ func ProbeAttachableVolumePlugins() []volume.VolumePlugin { allPlugins = append(allPlugins, portworx.ProbeVolumePlugins()...) allPlugins = append(allPlugins, vsphere_volume.ProbeVolumePlugins()...) allPlugins = append(allPlugins, azure_dd.ProbeVolumePlugins()...) - allPlugins = append(allPlugins, photon_pd.ProbeVolumePlugins()...) allPlugins = append(allPlugins, scaleio.ProbeVolumePlugins()...) allPlugins = append(allPlugins, storageos.ProbeVolumePlugins()...) allPlugins = append(allPlugins, fc.ProbeVolumePlugins()...) @@ -105,7 +103,6 @@ func ProbeExpandableVolumePlugins(config persistentvolumeconfig.VolumeConfigurat allPlugins = append(allPlugins, rbd.ProbeVolumePlugins()...) allPlugins = append(allPlugins, azure_dd.ProbeVolumePlugins()...) allPlugins = append(allPlugins, azure_file.ProbeVolumePlugins()...) - allPlugins = append(allPlugins, photon_pd.ProbeVolumePlugins()...) allPlugins = append(allPlugins, scaleio.ProbeVolumePlugins()...) allPlugins = append(allPlugins, storageos.ProbeVolumePlugins()...) allPlugins = append(allPlugins, fc.ProbeVolumePlugins()...) @@ -164,7 +161,6 @@ func ProbeControllerVolumePlugins(cloud cloudprovider.Interface, config persiste allPlugins = append(allPlugins, cinder.ProbeVolumePlugins()...) allPlugins = append(allPlugins, vsphere_volume.ProbeVolumePlugins()...) allPlugins = append(allPlugins, azure_dd.ProbeVolumePlugins()...) - allPlugins = append(allPlugins, photon_pd.ProbeVolumePlugins()...) if utilfeature.DefaultFeatureGate.Enabled(features.CSIInlineVolume) { allPlugins = append(allPlugins, csi.ProbeVolumePlugins()...) diff --git a/cmd/kubeadm/.import-restrictions b/cmd/kubeadm/.import-restrictions index 510a28f8525..a8e7f8f77c9 100644 --- a/cmd/kubeadm/.import-restrictions +++ b/cmd/kubeadm/.import-restrictions @@ -95,12 +95,9 @@ "k8s.io/kubernetes/pkg/cloudprovider/providers", "k8s.io/kubernetes/pkg/cloudprovider/providers/aws", "k8s.io/kubernetes/pkg/cloudprovider/providers/azure", - "k8s.io/kubernetes/pkg/cloudprovider/providers/cloudstack", "k8s.io/kubernetes/pkg/cloudprovider/providers/fake", "k8s.io/kubernetes/pkg/cloudprovider/providers/gce", "k8s.io/kubernetes/pkg/cloudprovider/providers/openstack", - "k8s.io/kubernetes/pkg/cloudprovider/providers/ovirt", - "k8s.io/kubernetes/pkg/cloudprovider/providers/photon", "k8s.io/kubernetes/pkg/cloudprovider/providers/vsphere", "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" ] diff --git a/cmd/kubelet/app/BUILD b/cmd/kubelet/app/BUILD index d26be77596e..01b645bd52e 100644 --- a/cmd/kubelet/app/BUILD +++ b/cmd/kubelet/app/BUILD @@ -99,7 +99,6 @@ go_library( "//pkg/volume/iscsi:go_default_library", "//pkg/volume/local:go_default_library", "//pkg/volume/nfs:go_default_library", - "//pkg/volume/photon_pd:go_default_library", "//pkg/volume/portworx:go_default_library", "//pkg/volume/projected:go_default_library", "//pkg/volume/quobyte:go_default_library", diff --git a/cmd/kubelet/app/plugins.go b/cmd/kubelet/app/plugins.go index c566016a270..7a0a7321211 100644 --- a/cmd/kubelet/app/plugins.go +++ b/cmd/kubelet/app/plugins.go @@ -44,7 +44,6 @@ import ( "k8s.io/kubernetes/pkg/volume/iscsi" "k8s.io/kubernetes/pkg/volume/local" "k8s.io/kubernetes/pkg/volume/nfs" - "k8s.io/kubernetes/pkg/volume/photon_pd" "k8s.io/kubernetes/pkg/volume/portworx" "k8s.io/kubernetes/pkg/volume/projected" "k8s.io/kubernetes/pkg/volume/quobyte" @@ -90,7 +89,6 @@ func ProbeVolumePlugins() []volume.VolumePlugin { allPlugins = append(allPlugins, configmap.ProbeVolumePlugins()...) allPlugins = append(allPlugins, vsphere_volume.ProbeVolumePlugins()...) allPlugins = append(allPlugins, azure_dd.ProbeVolumePlugins()...) - allPlugins = append(allPlugins, photon_pd.ProbeVolumePlugins()...) allPlugins = append(allPlugins, projected.ProbeVolumePlugins()...) allPlugins = append(allPlugins, portworx.ProbeVolumePlugins()...) allPlugins = append(allPlugins, scaleio.ProbeVolumePlugins()...) diff --git a/go.mod b/go.mod index 8198da04b03..585241fc21f 100644 --- a/go.mod +++ b/go.mod @@ -43,8 +43,6 @@ require ( github.com/coreos/rkt v1.30.0 // indirect github.com/cpuguy83/go-md2man v1.0.4 github.com/cyphar/filepath-securejoin v0.0.0-20170720062807-ae69057f2299 // indirect - github.com/d2g/dhcp4 v0.0.0-20170904100407-a1d1b6c41b1c - github.com/d2g/dhcp4client v0.0.0-20170829104524-6e570ed0a266 github.com/davecgh/go-spew v1.1.1 github.com/daviddengcn/go-colortext v0.0.0-20160507010035-511bcaf42ccd github.com/docker/distribution v0.0.0-20170726174610-edc3ab29cdff @@ -148,8 +146,6 @@ require ( github.com/vishvananda/netlink v0.0.0-20171020171820-b2de5d10e38e github.com/vishvananda/netns v0.0.0-20171111001504-be1fbeda1936 // indirect github.com/vmware/govmomi v0.20.1 - github.com/vmware/photon-controller-go-sdk v0.0.0-20170310013346-4a435daef6cc - github.com/xanzy/go-cloudstack v0.0.0-20160728180336-1e2cbf647e57 github.com/xlab/handysort v0.0.0-20150421192137-fb3537ed64a1 // indirect golang.org/x/crypto v0.0.0-20181025213731-e84da0312774 golang.org/x/lint v0.0.0-20181217174547-8f45f776aaf1 diff --git a/go.sum b/go.sum index a32bf5117bc..7c21b000e3e 100644 --- a/go.sum +++ b/go.sum @@ -89,10 +89,6 @@ github.com/cpuguy83/go-md2man v1.0.4 h1:OwjhDpK9YGCcI5CDf8HcdfsXqr6znFyAJfuZ27ix github.com/cpuguy83/go-md2man v1.0.4/go.mod h1:N6JayAiVKtlHSnuTCeuLSQVs75hb8q+dYQLjr7cDsKY= github.com/cyphar/filepath-securejoin v0.0.0-20170720062807-ae69057f2299 h1:2pOMM/RaFhI52FyCITl8aTf5HZ9LoHD8SkjbghAEG1E= github.com/cyphar/filepath-securejoin v0.0.0-20170720062807-ae69057f2299/go.mod h1:FpkQEhXnPnOthhzymB7CGsFk2G9VLXONKD9G7QGMM+4= -github.com/d2g/dhcp4 v0.0.0-20170904100407-a1d1b6c41b1c h1:Xo2rK1pzOm0jO6abTPIQwbAmqBIOj132otexc1mmzFc= -github.com/d2g/dhcp4 v0.0.0-20170904100407-a1d1b6c41b1c/go.mod h1:Ct2BUK8SB0YC1SMSibvLzxjeJLnrYEVLULFNiHY9YfQ= -github.com/d2g/dhcp4client v0.0.0-20170829104524-6e570ed0a266 h1:1iKpuOrCnaRBKKNoChzmVDXeoFuCS7wsooRncvzVPxo= -github.com/d2g/dhcp4client v0.0.0-20170829104524-6e570ed0a266/go.mod h1:j0hNfjhrt2SxUOw55nL0ATM/z4Yt3t2Kd1mW34z5W5s= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/daviddengcn/go-colortext v0.0.0-20160507010035-511bcaf42ccd h1:uVsMphB1eRx7xB1njzL3fuMdWRN8HtVzoUOItHMwv5c= @@ -388,10 +384,6 @@ github.com/vishvananda/netns v0.0.0-20171111001504-be1fbeda1936 h1:J9gO8RJCAFlln github.com/vishvananda/netns v0.0.0-20171111001504-be1fbeda1936/go.mod h1:ZjcWmFBXmLKZu9Nxj3WKYEafiSqer2rnvPr0en9UNpI= github.com/vmware/govmomi v0.20.1 h1:7b/SeTUB3tER8ZLGLLLH3xcnB2xeuLULXmfPFqPSRZA= github.com/vmware/govmomi v0.20.1/go.mod h1:URlwyTFZX72RmxtxuaFL2Uj3fD1JTvZdx59bHWk6aFU= -github.com/vmware/photon-controller-go-sdk v0.0.0-20170310013346-4a435daef6cc h1:uyYiBHCUWsifUdIWrBzUUq9B3FSZKFTAuUyMQczS1q8= -github.com/vmware/photon-controller-go-sdk v0.0.0-20170310013346-4a435daef6cc/go.mod h1:e6humHha1ekIwTCm+A5Qed5mG8V4JL+ChHcUOJ+L/8U= -github.com/xanzy/go-cloudstack v0.0.0-20160728180336-1e2cbf647e57 h1:3OK6oXqbbEUeWvTJgg1pZgNjzdCNE6hMu2TragCfwb8= -github.com/xanzy/go-cloudstack v0.0.0-20160728180336-1e2cbf647e57/go.mod h1:s3eL3z5pNXF5FVybcT+LIVdId8pYn709yv6v5mrkrQE= github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18 h1:MPPkRncZLN9Kh4MEFmbnK4h3BD7AUmskWv2+EeZJCCs= github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xlab/handysort v0.0.0-20150421192137-fb3537ed64a1 h1:j2hhcujLRHAg872RWAV5yaUrEjHEObwDv3aImCaNLek= diff --git a/hack/.golint_failures b/hack/.golint_failures index 795f37bf204..b4734a30b62 100644 --- a/hack/.golint_failures +++ b/hack/.golint_failures @@ -51,7 +51,6 @@ pkg/apis/scheduling/v1beta1 pkg/apis/storage pkg/apis/storage/v1 pkg/apis/storage/v1beta1 -pkg/cloudprovider/providers/photon pkg/controller pkg/controller/apis/config/v1alpha1 pkg/controller/certificates @@ -315,7 +314,6 @@ pkg/volume/csi/csiv0 pkg/volume/csi/fake pkg/volume/git_repo pkg/volume/iscsi -pkg/volume/photon_pd pkg/volume/rbd pkg/volume/scaleio pkg/volume/storageos diff --git a/pkg/cloudprovider/providers/BUILD b/pkg/cloudprovider/providers/BUILD index 66dc0a30f05..5bccc7c4787 100644 --- a/pkg/cloudprovider/providers/BUILD +++ b/pkg/cloudprovider/providers/BUILD @@ -13,10 +13,7 @@ go_library( "//cmd/kubelet/app:__pkg__", ], deps = [ - "//pkg/cloudprovider/providers/cloudstack:go_default_library", "//pkg/cloudprovider/providers/openstack:go_default_library", - "//pkg/cloudprovider/providers/ovirt:go_default_library", - "//pkg/cloudprovider/providers/photon:go_default_library", "//staging/src/k8s.io/legacy-cloud-providers/aws:go_default_library", "//staging/src/k8s.io/legacy-cloud-providers/azure:go_default_library", "//staging/src/k8s.io/legacy-cloud-providers/gce:go_default_library", @@ -35,10 +32,7 @@ filegroup( name = "all-srcs", srcs = [ ":package-srcs", - "//pkg/cloudprovider/providers/cloudstack:all-srcs", "//pkg/cloudprovider/providers/openstack:all-srcs", - "//pkg/cloudprovider/providers/ovirt:all-srcs", - "//pkg/cloudprovider/providers/photon:all-srcs", ], tags = ["automanaged"], ) diff --git a/pkg/cloudprovider/providers/cloudstack/BUILD b/pkg/cloudprovider/providers/cloudstack/BUILD deleted file mode 100644 index 65cd15f2572..00000000000 --- a/pkg/cloudprovider/providers/cloudstack/BUILD +++ /dev/null @@ -1,88 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -load( - "@io_bazel_rules_go//go:def.bzl", - "go_library", - "go_test", -) - -go_library( - name = "go_default_library", - srcs = [ - "cloudstack.go", - "cloudstack_instances.go", - "cloudstack_loadbalancer.go", - "metadata.go", - "metadata_linux.go", - "metadata_other.go", - ], - importpath = "k8s.io/kubernetes/pkg/cloudprovider/providers/cloudstack", - deps = [ - "//staging/src/k8s.io/api/core/v1:go_default_library", - "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", - "//staging/src/k8s.io/cloud-provider:go_default_library", - "//vendor/github.com/d2g/dhcp4:go_default_library", - "//vendor/github.com/kardianos/osext:go_default_library", - "//vendor/github.com/xanzy/go-cloudstack/cloudstack:go_default_library", - "//vendor/gopkg.in/gcfg.v1:go_default_library", - "//vendor/k8s.io/klog:go_default_library", - ] + select({ - "@io_bazel_rules_go//go/platform:android": [ - "//vendor/github.com/d2g/dhcp4client:go_default_library", - ], - "@io_bazel_rules_go//go/platform:darwin": [ - "//vendor/github.com/d2g/dhcp4client:go_default_library", - ], - "@io_bazel_rules_go//go/platform:dragonfly": [ - "//vendor/github.com/d2g/dhcp4client:go_default_library", - ], - "@io_bazel_rules_go//go/platform:freebsd": [ - "//vendor/github.com/d2g/dhcp4client:go_default_library", - ], - "@io_bazel_rules_go//go/platform:linux": [ - "//vendor/github.com/d2g/dhcp4client:go_default_library", - ], - "@io_bazel_rules_go//go/platform:nacl": [ - "//vendor/github.com/d2g/dhcp4client:go_default_library", - ], - "@io_bazel_rules_go//go/platform:netbsd": [ - "//vendor/github.com/d2g/dhcp4client:go_default_library", - ], - "@io_bazel_rules_go//go/platform:openbsd": [ - "//vendor/github.com/d2g/dhcp4client:go_default_library", - ], - "@io_bazel_rules_go//go/platform:plan9": [ - "//vendor/github.com/d2g/dhcp4client:go_default_library", - ], - "@io_bazel_rules_go//go/platform:solaris": [ - "//vendor/github.com/d2g/dhcp4client:go_default_library", - ], - "@io_bazel_rules_go//go/platform:windows": [ - "//vendor/github.com/d2g/dhcp4client:go_default_library", - ], - "//conditions:default": [], - }), -) - -go_test( - name = "go_default_test", - srcs = ["cloudstack_test.go"], - embed = [":go_default_library"], - deps = [ - "//staging/src/k8s.io/api/core/v1:go_default_library", - "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", - ], -) - -filegroup( - name = "package-srcs", - srcs = glob(["**"]), - tags = ["automanaged"], - visibility = ["//visibility:private"], -) - -filegroup( - name = "all-srcs", - srcs = [":package-srcs"], - tags = ["automanaged"], -) diff --git a/pkg/cloudprovider/providers/cloudstack/OWNERS b/pkg/cloudprovider/providers/cloudstack/OWNERS deleted file mode 100644 index 111e3dd19d5..00000000000 --- a/pkg/cloudprovider/providers/cloudstack/OWNERS +++ /dev/null @@ -1,6 +0,0 @@ -# See the OWNERS docs at https://go.k8s.io/owners - -approvers: -- ngtuna -- sebgoa -- svanharmelen diff --git a/pkg/cloudprovider/providers/cloudstack/cloudstack.go b/pkg/cloudprovider/providers/cloudstack/cloudstack.go deleted file mode 100644 index 222a0356293..00000000000 --- a/pkg/cloudprovider/providers/cloudstack/cloudstack.go +++ /dev/null @@ -1,265 +0,0 @@ -/* -Copyright 2016 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package cloudstack - -import ( - "context" - "errors" - "fmt" - "io" - "os" - "path/filepath" - - "github.com/kardianos/osext" - "github.com/xanzy/go-cloudstack/cloudstack" - "gopkg.in/gcfg.v1" - "k8s.io/apimachinery/pkg/types" - cloudprovider "k8s.io/cloud-provider" - "k8s.io/klog" -) - -// ProviderName is the name of this cloud provider. -const ProviderName = "cloudstack" - -// CSConfig wraps the config for the CloudStack cloud provider. -type CSConfig struct { - Global struct { - APIURL string `gcfg:"api-url"` - APIKey string `gcfg:"api-key"` - SecretKey string `gcfg:"secret-key"` - SSLNoVerify bool `gcfg:"ssl-no-verify"` - ProjectID string `gcfg:"project-id"` - Zone string `gcfg:"zone"` - } -} - -// CSCloud is an implementation of Interface for CloudStack. -type CSCloud struct { - client *cloudstack.CloudStackClient - metadata *metadata - projectID string // If non-"", all resources will be created within this project - zone string -} - -func init() { - cloudprovider.RegisterCloudProvider(ProviderName, func(config io.Reader) (cloudprovider.Interface, error) { - cfg, err := readConfig(config) - if err != nil { - return nil, err - } - - return newCSCloud(cfg) - }) -} - -func readConfig(config io.Reader) (*CSConfig, error) { - cfg := &CSConfig{} - - if config == nil { - return cfg, nil - } - - if err := gcfg.ReadInto(cfg, config); err != nil { - return nil, fmt.Errorf("could not parse cloud provider config: %v", err) - } - - return cfg, nil -} - -// newCSCloud creates a new instance of CSCloud. -func newCSCloud(cfg *CSConfig) (*CSCloud, error) { - cs := &CSCloud{ - projectID: cfg.Global.ProjectID, - zone: cfg.Global.Zone, - } - - exe, err := osext.Executable() - if err != nil { - return nil, fmt.Errorf("cloud not find the service executable: %v", err) - } - - // When running the kubelet service it's fine to not specify a config file (or only a - // partial config file) as all needed info can be retrieved anonymously using metadata. - if filepath.Base(exe) == "kubelet" || filepath.Base(exe) == "kubelet.exe" { - // In CloudStack your metadata is always served by the DHCP server. - dhcpServer, err := findDHCPServer() - if err == nil { - klog.V(4).Infof("Found metadata server: %v", dhcpServer) - cs.metadata = &metadata{dhcpServer: dhcpServer, zone: cs.zone} - } else { - klog.Errorf("Error searching metadata server: %v", err) - } - } - - if cfg.Global.APIURL != "" && cfg.Global.APIKey != "" && cfg.Global.SecretKey != "" { - cs.client = cloudstack.NewAsyncClient(cfg.Global.APIURL, cfg.Global.APIKey, cfg.Global.SecretKey, !cfg.Global.SSLNoVerify) - } - - if cs.client == nil { - if cs.metadata != nil { - klog.V(2).Infof("No API URL, key and secret are provided, so only using metadata!") - } else { - return nil, errors.New("no cloud provider config given") - } - } - - return cs, nil -} - -var _ cloudprovider.Interface = (*CSCloud)(nil) -var _ cloudprovider.Instances = (*CSCloud)(nil) -var _ cloudprovider.LoadBalancer = (*CSCloud)(nil) -var _ cloudprovider.Zones = (*CSCloud)(nil) - -// Initialize passes a Kubernetes clientBuilder interface to the cloud provider -func (cs *CSCloud) Initialize(clientBuilder cloudprovider.ControllerClientBuilder, stop <-chan struct{}) { -} - -// LoadBalancer returns an implementation of LoadBalancer for CloudStack. -func (cs *CSCloud) LoadBalancer() (cloudprovider.LoadBalancer, bool) { - if cs.client == nil { - return nil, false - } - - return cs, true -} - -// Instances returns an implementation of Instances for CloudStack. -func (cs *CSCloud) Instances() (cloudprovider.Instances, bool) { - if cs.metadata != nil { - return cs.metadata, true - } - - if cs.client == nil { - return nil, false - } - - return cs, true -} - -// Zones returns an implementation of Zones for CloudStack. -func (cs *CSCloud) Zones() (cloudprovider.Zones, bool) { - if cs.metadata != nil { - return cs.metadata, true - } - - if cs.client == nil { - return nil, false - } - - return cs, true -} - -// Clusters returns an implementation of Clusters for CloudStack. -func (cs *CSCloud) Clusters() (cloudprovider.Clusters, bool) { - if cs.client == nil { - return nil, false - } - - return nil, false -} - -// Routes returns an implementation of Routes for CloudStack. -func (cs *CSCloud) Routes() (cloudprovider.Routes, bool) { - if cs.client == nil { - return nil, false - } - - return nil, false -} - -// ProviderName returns the cloud provider ID. -func (cs *CSCloud) ProviderName() string { - return ProviderName -} - -// HasClusterID returns true if the cluster has a clusterID -func (cs *CSCloud) HasClusterID() bool { - return true -} - -// GetZone returns the Zone containing the region that the program is running in. -func (cs *CSCloud) GetZone(ctx context.Context) (cloudprovider.Zone, error) { - zone := cloudprovider.Zone{} - - if cs.zone == "" { - hostname, err := os.Hostname() - if err != nil { - return zone, fmt.Errorf("failed to get hostname for retrieving the zone: %v", err) - } - - instance, count, err := cs.client.VirtualMachine.GetVirtualMachineByName(hostname) - if err != nil { - if count == 0 { - return zone, fmt.Errorf("could not find instance for retrieving the zone: %v", err) - } - return zone, fmt.Errorf("error getting instance for retrieving the zone: %v", err) - } - - cs.zone = instance.Zonename - } - - klog.V(2).Infof("Current zone is %v", cs.zone) - zone.FailureDomain = cs.zone - zone.Region = cs.zone - - return zone, nil -} - -// GetZoneByProviderID returns the Zone, found by using the provider ID. -func (cs *CSCloud) GetZoneByProviderID(ctx context.Context, providerID string) (cloudprovider.Zone, error) { - zone := cloudprovider.Zone{} - - instance, count, err := cs.client.VirtualMachine.GetVirtualMachineByID( - providerID, - cloudstack.WithProject(cs.projectID), - ) - if err != nil { - if count == 0 { - return zone, fmt.Errorf("could not find node by ID: %v", providerID) - } - return zone, fmt.Errorf("error retrieving zone: %v", err) - } - - klog.V(2).Infof("Current zone is %v", cs.zone) - zone.FailureDomain = instance.Zonename - zone.Region = instance.Zonename - - return zone, nil -} - -// GetZoneByNodeName returns the Zone, found by using the node name. -func (cs *CSCloud) GetZoneByNodeName(ctx context.Context, nodeName types.NodeName) (cloudprovider.Zone, error) { - zone := cloudprovider.Zone{} - - instance, count, err := cs.client.VirtualMachine.GetVirtualMachineByName( - string(nodeName), - cloudstack.WithProject(cs.projectID), - ) - if err != nil { - if count == 0 { - return zone, fmt.Errorf("could not find node: %v", nodeName) - } - return zone, fmt.Errorf("error retrieving zone: %v", err) - } - - klog.V(2).Infof("Current zone is %v", cs.zone) - zone.FailureDomain = instance.Zonename - zone.Region = instance.Zonename - - return zone, nil -} diff --git a/pkg/cloudprovider/providers/cloudstack/cloudstack_instances.go b/pkg/cloudprovider/providers/cloudstack/cloudstack_instances.go deleted file mode 100644 index 55a81bdaa6f..00000000000 --- a/pkg/cloudprovider/providers/cloudstack/cloudstack_instances.go +++ /dev/null @@ -1,164 +0,0 @@ -/* -Copyright 2016 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package cloudstack - -import ( - "context" - "errors" - "fmt" - - "github.com/xanzy/go-cloudstack/cloudstack" - "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/types" - cloudprovider "k8s.io/cloud-provider" - "k8s.io/klog" -) - -// NodeAddresses returns the addresses of the specified instance. -func (cs *CSCloud) NodeAddresses(ctx context.Context, name types.NodeName) ([]v1.NodeAddress, error) { - instance, count, err := cs.client.VirtualMachine.GetVirtualMachineByName( - string(name), - cloudstack.WithProject(cs.projectID), - ) - if err != nil { - if count == 0 { - return nil, cloudprovider.InstanceNotFound - } - return nil, fmt.Errorf("error retrieving node addresses: %v", err) - } - - return cs.nodeAddresses(instance) -} - -// NodeAddressesByProviderID returns the addresses of the specified instance. -func (cs *CSCloud) NodeAddressesByProviderID(ctx context.Context, providerID string) ([]v1.NodeAddress, error) { - instance, count, err := cs.client.VirtualMachine.GetVirtualMachineByID( - providerID, - cloudstack.WithProject(cs.projectID), - ) - if err != nil { - if count == 0 { - return nil, cloudprovider.InstanceNotFound - } - return nil, fmt.Errorf("error retrieving node addresses: %v", err) - } - - return cs.nodeAddresses(instance) -} - -func (cs *CSCloud) nodeAddresses(instance *cloudstack.VirtualMachine) ([]v1.NodeAddress, error) { - if len(instance.Nic) == 0 { - return nil, errors.New("instance does not have an internal IP") - } - - addresses := []v1.NodeAddress{ - {Type: v1.NodeInternalIP, Address: instance.Nic[0].Ipaddress}, - } - - if instance.Hostname != "" { - addresses = append(addresses, v1.NodeAddress{Type: v1.NodeHostName, Address: instance.Hostname}) - } - - if instance.Publicip != "" { - addresses = append(addresses, v1.NodeAddress{Type: v1.NodeExternalIP, Address: instance.Publicip}) - } else { - // Since there is no sane way to determine the external IP if the host isn't - // using static NAT, we will just fire a log message and omit the external IP. - klog.V(4).Infof("Could not determine the public IP of host %v (%v)", instance.Name, instance.Id) - } - - return addresses, nil -} - -// InstanceID returns the cloud provider ID of the specified instance. -func (cs *CSCloud) InstanceID(ctx context.Context, name types.NodeName) (string, error) { - instance, count, err := cs.client.VirtualMachine.GetVirtualMachineByName( - string(name), - cloudstack.WithProject(cs.projectID), - ) - if err != nil { - if count == 0 { - return "", cloudprovider.InstanceNotFound - } - return "", fmt.Errorf("error retrieving instance ID: %v", err) - } - - return instance.Id, nil -} - -// InstanceType returns the type of the specified instance. -func (cs *CSCloud) InstanceType(ctx context.Context, name types.NodeName) (string, error) { - instance, count, err := cs.client.VirtualMachine.GetVirtualMachineByName( - string(name), - cloudstack.WithProject(cs.projectID), - ) - if err != nil { - if count == 0 { - return "", cloudprovider.InstanceNotFound - } - return "", fmt.Errorf("error retrieving instance type: %v", err) - } - - return instance.Serviceofferingname, nil -} - -// InstanceTypeByProviderID returns the type of the specified instance. -func (cs *CSCloud) InstanceTypeByProviderID(ctx context.Context, providerID string) (string, error) { - instance, count, err := cs.client.VirtualMachine.GetVirtualMachineByID( - providerID, - cloudstack.WithProject(cs.projectID), - ) - if err != nil { - if count == 0 { - return "", cloudprovider.InstanceNotFound - } - return "", fmt.Errorf("error retrieving instance type: %v", err) - } - - return instance.Serviceofferingname, nil -} - -// AddSSHKeyToAllInstances is currently not implemented. -func (cs *CSCloud) AddSSHKeyToAllInstances(ctx context.Context, user string, keyData []byte) error { - return cloudprovider.NotImplemented -} - -// CurrentNodeName returns the name of the node we are currently running on. -func (cs *CSCloud) CurrentNodeName(ctx context.Context, hostname string) (types.NodeName, error) { - return types.NodeName(hostname), nil -} - -// InstanceExistsByProviderID returns if the instance still exists. -func (cs *CSCloud) InstanceExistsByProviderID(ctx context.Context, providerID string) (bool, error) { - _, count, err := cs.client.VirtualMachine.GetVirtualMachineByID( - providerID, - cloudstack.WithProject(cs.projectID), - ) - if err != nil { - if count == 0 { - return false, nil - } - return false, fmt.Errorf("error retrieving instance: %v", err) - } - - return true, nil -} - -// InstanceShutdownByProviderID returns true if the instance is in safe state to detach volumes -func (cs *CSCloud) InstanceShutdownByProviderID(ctx context.Context, providerID string) (bool, error) { - return false, cloudprovider.NotImplemented -} diff --git a/pkg/cloudprovider/providers/cloudstack/cloudstack_loadbalancer.go b/pkg/cloudprovider/providers/cloudstack/cloudstack_loadbalancer.go deleted file mode 100644 index 64971d02cf2..00000000000 --- a/pkg/cloudprovider/providers/cloudstack/cloudstack_loadbalancer.go +++ /dev/null @@ -1,549 +0,0 @@ -/* -Copyright 2016 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package cloudstack - -import ( - "context" - "fmt" - "strconv" - - "github.com/xanzy/go-cloudstack/cloudstack" - "k8s.io/klog" - - "k8s.io/api/core/v1" - cloudprovider "k8s.io/cloud-provider" -) - -type loadBalancer struct { - *cloudstack.CloudStackClient - - name string - algorithm string - hostIDs []string - ipAddr string - ipAddrID string - networkID string - projectID string - rules map[string]*cloudstack.LoadBalancerRule -} - -// GetLoadBalancer returns whether the specified load balancer exists, and if so, what its status is. -func (cs *CSCloud) GetLoadBalancer(ctx context.Context, clusterName string, service *v1.Service) (*v1.LoadBalancerStatus, bool, error) { - klog.V(4).Infof("GetLoadBalancer(%v, %v, %v)", clusterName, service.Namespace, service.Name) - - // Get the load balancer details and existing rules. - lb, err := cs.getLoadBalancer(service) - if err != nil { - return nil, false, err - } - - // If we don't have any rules, the load balancer does not exist. - if len(lb.rules) == 0 { - return nil, false, nil - } - - klog.V(4).Infof("Found a load balancer associated with IP %v", lb.ipAddr) - - status := &v1.LoadBalancerStatus{} - status.Ingress = append(status.Ingress, v1.LoadBalancerIngress{IP: lb.ipAddr}) - - return status, true, nil -} - -// EnsureLoadBalancer creates a new load balancer, or updates the existing one. Returns the status of the balancer. -func (cs *CSCloud) EnsureLoadBalancer(ctx context.Context, clusterName string, service *v1.Service, nodes []*v1.Node) (status *v1.LoadBalancerStatus, err error) { - klog.V(4).Infof("EnsureLoadBalancer(%v, %v, %v, %v, %v, %v)", clusterName, service.Namespace, service.Name, service.Spec.LoadBalancerIP, service.Spec.Ports, nodes) - - if len(service.Spec.Ports) == 0 { - return nil, fmt.Errorf("requested load balancer with no ports") - } - - // Get the load balancer details and existing rules. - lb, err := cs.getLoadBalancer(service) - if err != nil { - return nil, err - } - - // Set the load balancer algorithm. - switch service.Spec.SessionAffinity { - case v1.ServiceAffinityNone: - lb.algorithm = "roundrobin" - case v1.ServiceAffinityClientIP: - lb.algorithm = "source" - default: - return nil, fmt.Errorf("unsupported load balancer affinity: %v", service.Spec.SessionAffinity) - } - - // Verify that all the hosts belong to the same network, and retrieve their ID's. - lb.hostIDs, lb.networkID, err = cs.verifyHosts(nodes) - if err != nil { - return nil, err - } - - if !lb.hasLoadBalancerIP() { - // Create or retrieve the load balancer IP. - if err := lb.getLoadBalancerIP(service.Spec.LoadBalancerIP); err != nil { - return nil, err - } - - if lb.ipAddr != "" && lb.ipAddr != service.Spec.LoadBalancerIP { - defer func(lb *loadBalancer) { - if err != nil { - if err := lb.releaseLoadBalancerIP(); err != nil { - klog.Errorf(err.Error()) - } - } - }(lb) - } - } - - klog.V(4).Infof("Load balancer %v is associated with IP %v", lb.name, lb.ipAddr) - - for _, port := range service.Spec.Ports { - // All ports have their own load balancer rule, so add the port to lbName to keep the names unique. - lbRuleName := fmt.Sprintf("%s-%d", lb.name, port.Port) - - // If the load balancer rule exists and is up-to-date, we move on to the next rule. - exists, needsUpdate, err := lb.checkLoadBalancerRule(lbRuleName, port) - if err != nil { - return nil, err - } - if exists && !needsUpdate { - klog.V(4).Infof("Load balancer rule %v is up-to-date", lbRuleName) - // Delete the rule from the map, to prevent it being deleted. - delete(lb.rules, lbRuleName) - continue - } - - if needsUpdate { - klog.V(4).Infof("Updating load balancer rule: %v", lbRuleName) - if err := lb.updateLoadBalancerRule(lbRuleName); err != nil { - return nil, err - } - // Delete the rule from the map, to prevent it being deleted. - delete(lb.rules, lbRuleName) - continue - } - - klog.V(4).Infof("Creating load balancer rule: %v", lbRuleName) - lbRule, err := lb.createLoadBalancerRule(lbRuleName, port) - if err != nil { - return nil, err - } - - klog.V(4).Infof("Assigning hosts (%v) to load balancer rule: %v", lb.hostIDs, lbRuleName) - if err = lb.assignHostsToRule(lbRule, lb.hostIDs); err != nil { - return nil, err - } - - } - - // Cleanup any rules that are now still in the rules map, as they are no longer needed. - for _, lbRule := range lb.rules { - klog.V(4).Infof("Deleting obsolete load balancer rule: %v", lbRule.Name) - if err := lb.deleteLoadBalancerRule(lbRule); err != nil { - return nil, err - } - } - - status = &v1.LoadBalancerStatus{} - status.Ingress = []v1.LoadBalancerIngress{{IP: lb.ipAddr}} - - return status, nil -} - -// UpdateLoadBalancer updates hosts under the specified load balancer. -func (cs *CSCloud) UpdateLoadBalancer(ctx context.Context, clusterName string, service *v1.Service, nodes []*v1.Node) error { - klog.V(4).Infof("UpdateLoadBalancer(%v, %v, %v, %v)", clusterName, service.Namespace, service.Name, nodes) - - // Get the load balancer details and existing rules. - lb, err := cs.getLoadBalancer(service) - if err != nil { - return err - } - - // Verify that all the hosts belong to the same network, and retrieve their ID's. - lb.hostIDs, _, err = cs.verifyHosts(nodes) - if err != nil { - return err - } - - for _, lbRule := range lb.rules { - p := lb.LoadBalancer.NewListLoadBalancerRuleInstancesParams(lbRule.Id) - - // Retrieve all VMs currently associated to this load balancer rule. - l, err := lb.LoadBalancer.ListLoadBalancerRuleInstances(p) - if err != nil { - return fmt.Errorf("error retrieving associated instances: %v", err) - } - - assign, remove := symmetricDifference(lb.hostIDs, l.LoadBalancerRuleInstances) - - if len(assign) > 0 { - klog.V(4).Infof("Assigning new hosts (%v) to load balancer rule: %v", assign, lbRule.Name) - if err := lb.assignHostsToRule(lbRule, assign); err != nil { - return err - } - } - - if len(remove) > 0 { - klog.V(4).Infof("Removing old hosts (%v) from load balancer rule: %v", assign, lbRule.Name) - if err := lb.removeHostsFromRule(lbRule, remove); err != nil { - return err - } - } - } - - return nil -} - -// EnsureLoadBalancerDeleted deletes the specified load balancer if it exists, returning -// nil if the load balancer specified either didn't exist or was successfully deleted. -func (cs *CSCloud) EnsureLoadBalancerDeleted(ctx context.Context, clusterName string, service *v1.Service) error { - klog.V(4).Infof("EnsureLoadBalancerDeleted(%v, %v, %v)", clusterName, service.Namespace, service.Name) - - // Get the load balancer details and existing rules. - lb, err := cs.getLoadBalancer(service) - if err != nil { - return err - } - - for _, lbRule := range lb.rules { - klog.V(4).Infof("Deleting load balancer rule: %v", lbRule.Name) - if err := lb.deleteLoadBalancerRule(lbRule); err != nil { - return err - } - } - - if lb.ipAddr != "" && lb.ipAddr != service.Spec.LoadBalancerIP { - klog.V(4).Infof("Releasing load balancer IP: %v", lb.ipAddr) - if err := lb.releaseLoadBalancerIP(); err != nil { - return err - } - } - - return nil -} - -// GetLoadBalancerName retrieves the name of the LoadBalancer. -func (cs *CSCloud) GetLoadBalancerName(ctx context.Context, clusterName string, service *v1.Service) string { - return cloudprovider.DefaultLoadBalancerName(service) -} - -// getLoadBalancer retrieves the IP address and ID and all the existing rules it can find. -func (cs *CSCloud) getLoadBalancer(service *v1.Service) (*loadBalancer, error) { - lb := &loadBalancer{ - CloudStackClient: cs.client, - name: cs.GetLoadBalancerName(context.TODO(), "", service), - projectID: cs.projectID, - rules: make(map[string]*cloudstack.LoadBalancerRule), - } - - p := cs.client.LoadBalancer.NewListLoadBalancerRulesParams() - p.SetKeyword(lb.name) - p.SetListall(true) - - if cs.projectID != "" { - p.SetProjectid(cs.projectID) - } - - l, err := cs.client.LoadBalancer.ListLoadBalancerRules(p) - if err != nil { - return nil, fmt.Errorf("error retrieving load balancer rules: %v", err) - } - - for _, lbRule := range l.LoadBalancerRules { - lb.rules[lbRule.Name] = lbRule - - if lb.ipAddr != "" && lb.ipAddr != lbRule.Publicip { - klog.Warningf("Load balancer for service %v/%v has rules associated with different IP's: %v, %v", service.Namespace, service.Name, lb.ipAddr, lbRule.Publicip) - } - - lb.ipAddr = lbRule.Publicip - lb.ipAddrID = lbRule.Publicipid - } - - klog.V(4).Infof("Load balancer %v contains %d rule(s)", lb.name, len(lb.rules)) - - return lb, nil -} - -// verifyHosts verifies if all hosts belong to the same network, and returns the host ID's and network ID. -func (cs *CSCloud) verifyHosts(nodes []*v1.Node) ([]string, string, error) { - hostNames := map[string]bool{} - for _, node := range nodes { - hostNames[node.Name] = true - } - - p := cs.client.VirtualMachine.NewListVirtualMachinesParams() - p.SetListall(true) - - if cs.projectID != "" { - p.SetProjectid(cs.projectID) - } - - l, err := cs.client.VirtualMachine.ListVirtualMachines(p) - if err != nil { - return nil, "", fmt.Errorf("error retrieving list of hosts: %v", err) - } - - var hostIDs []string - var networkID string - - // Check if the virtual machine is in the hosts slice, then add the corresponding ID. - for _, vm := range l.VirtualMachines { - if hostNames[vm.Name] { - if networkID != "" && networkID != vm.Nic[0].Networkid { - return nil, "", fmt.Errorf("found hosts that belong to different networks") - } - - networkID = vm.Nic[0].Networkid - hostIDs = append(hostIDs, vm.Id) - } - } - - return hostIDs, networkID, nil -} - -// hasLoadBalancerIP returns true if we have a load balancer address and ID. -func (lb *loadBalancer) hasLoadBalancerIP() bool { - return lb.ipAddr != "" && lb.ipAddrID != "" -} - -// getLoadBalancerIP retieves an existing IP or associates a new IP. -func (lb *loadBalancer) getLoadBalancerIP(loadBalancerIP string) error { - if loadBalancerIP != "" { - return lb.getPublicIPAddress(loadBalancerIP) - } - - return lb.associatePublicIPAddress() -} - -// getPublicIPAddressID retrieves the ID of the given IP, and sets the address and it's ID. -func (lb *loadBalancer) getPublicIPAddress(loadBalancerIP string) error { - klog.V(4).Infof("Retrieve load balancer IP details: %v", loadBalancerIP) - - p := lb.Address.NewListPublicIpAddressesParams() - p.SetIpaddress(loadBalancerIP) - p.SetListall(true) - - if lb.projectID != "" { - p.SetProjectid(lb.projectID) - } - - l, err := lb.Address.ListPublicIpAddresses(p) - if err != nil { - return fmt.Errorf("error retrieving IP address: %v", err) - } - - if l.Count != 1 { - return fmt.Errorf("could not find IP address %v", loadBalancerIP) - } - - lb.ipAddr = l.PublicIpAddresses[0].Ipaddress - lb.ipAddrID = l.PublicIpAddresses[0].Id - - return nil -} - -// associatePublicIPAddress associates a new IP and sets the address and it's ID. -func (lb *loadBalancer) associatePublicIPAddress() error { - klog.V(4).Infof("Allocate new IP for load balancer: %v", lb.name) - // If a network belongs to a VPC, the IP address needs to be associated with - // the VPC instead of with the network. - network, count, err := lb.Network.GetNetworkByID(lb.networkID, cloudstack.WithProject(lb.projectID)) - if err != nil { - if count == 0 { - return fmt.Errorf("could not find network %v", lb.networkID) - } - return fmt.Errorf("error retrieving network: %v", err) - } - - p := lb.Address.NewAssociateIpAddressParams() - - if network.Vpcid != "" { - p.SetVpcid(network.Vpcid) - } else { - p.SetNetworkid(lb.networkID) - } - - if lb.projectID != "" { - p.SetProjectid(lb.projectID) - } - - // Associate a new IP address - r, err := lb.Address.AssociateIpAddress(p) - if err != nil { - return fmt.Errorf("error associating new IP address: %v", err) - } - - lb.ipAddr = r.Ipaddress - lb.ipAddrID = r.Id - - return nil -} - -// releasePublicIPAddress releases an associated IP. -func (lb *loadBalancer) releaseLoadBalancerIP() error { - p := lb.Address.NewDisassociateIpAddressParams(lb.ipAddrID) - - if _, err := lb.Address.DisassociateIpAddress(p); err != nil { - return fmt.Errorf("error releasing load balancer IP %v: %v", lb.ipAddr, err) - } - - return nil -} - -// checkLoadBalancerRule checks if the rule already exists and if it does, if it can be updated. If -// it does exist but cannot be updated, it will delete the existing rule so it can be created again. -func (lb *loadBalancer) checkLoadBalancerRule(lbRuleName string, port v1.ServicePort) (bool, bool, error) { - lbRule, ok := lb.rules[lbRuleName] - if !ok { - return false, false, nil - } - - // Check if any of the values we cannot update (those that require a new load balancer rule) are changed. - if lbRule.Publicip == lb.ipAddr && lbRule.Privateport == strconv.Itoa(int(port.NodePort)) && lbRule.Publicport == strconv.Itoa(int(port.Port)) { - return true, lbRule.Algorithm != lb.algorithm, nil - } - - // Delete the load balancer rule so we can create a new one using the new values. - if err := lb.deleteLoadBalancerRule(lbRule); err != nil { - return false, false, err - } - - return false, false, nil -} - -// updateLoadBalancerRule updates a load balancer rule. -func (lb *loadBalancer) updateLoadBalancerRule(lbRuleName string) error { - lbRule := lb.rules[lbRuleName] - - p := lb.LoadBalancer.NewUpdateLoadBalancerRuleParams(lbRule.Id) - p.SetAlgorithm(lb.algorithm) - - _, err := lb.LoadBalancer.UpdateLoadBalancerRule(p) - return err -} - -// createLoadBalancerRule creates a new load balancer rule and returns it's ID. -func (lb *loadBalancer) createLoadBalancerRule(lbRuleName string, port v1.ServicePort) (*cloudstack.LoadBalancerRule, error) { - p := lb.LoadBalancer.NewCreateLoadBalancerRuleParams( - lb.algorithm, - lbRuleName, - int(port.NodePort), - int(port.Port), - ) - - p.SetNetworkid(lb.networkID) - p.SetPublicipid(lb.ipAddrID) - - switch port.Protocol { - case v1.ProtocolTCP: - p.SetProtocol("TCP") - case v1.ProtocolUDP: - p.SetProtocol("UDP") - default: - return nil, fmt.Errorf("unsupported load balancer protocol: %v", port.Protocol) - } - - // Do not create corresponding firewall rule. - p.SetOpenfirewall(false) - - // Create a new load balancer rule. - r, err := lb.LoadBalancer.CreateLoadBalancerRule(p) - if err != nil { - return nil, fmt.Errorf("error creating load balancer rule %v: %v", lbRuleName, err) - } - - lbRule := &cloudstack.LoadBalancerRule{ - Id: r.Id, - Algorithm: r.Algorithm, - Cidrlist: r.Cidrlist, - Name: r.Name, - Networkid: r.Networkid, - Privateport: r.Privateport, - Publicport: r.Publicport, - Publicip: r.Publicip, - Publicipid: r.Publicipid, - } - - return lbRule, nil -} - -// deleteLoadBalancerRule deletes a load balancer rule. -func (lb *loadBalancer) deleteLoadBalancerRule(lbRule *cloudstack.LoadBalancerRule) error { - p := lb.LoadBalancer.NewDeleteLoadBalancerRuleParams(lbRule.Id) - - if _, err := lb.LoadBalancer.DeleteLoadBalancerRule(p); err != nil { - return fmt.Errorf("error deleting load balancer rule %v: %v", lbRule.Name, err) - } - - // Delete the rule from the map as it no longer exists - delete(lb.rules, lbRule.Name) - - return nil -} - -// assignHostsToRule assigns hosts to a load balancer rule. -func (lb *loadBalancer) assignHostsToRule(lbRule *cloudstack.LoadBalancerRule, hostIDs []string) error { - p := lb.LoadBalancer.NewAssignToLoadBalancerRuleParams(lbRule.Id) - p.SetVirtualmachineids(hostIDs) - - if _, err := lb.LoadBalancer.AssignToLoadBalancerRule(p); err != nil { - return fmt.Errorf("error assigning hosts to load balancer rule %v: %v", lbRule.Name, err) - } - - return nil -} - -// removeHostsFromRule removes hosts from a load balancer rule. -func (lb *loadBalancer) removeHostsFromRule(lbRule *cloudstack.LoadBalancerRule, hostIDs []string) error { - p := lb.LoadBalancer.NewRemoveFromLoadBalancerRuleParams(lbRule.Id) - p.SetVirtualmachineids(hostIDs) - - if _, err := lb.LoadBalancer.RemoveFromLoadBalancerRule(p); err != nil { - return fmt.Errorf("error removing hosts from load balancer rule %v: %v", lbRule.Name, err) - } - - return nil -} - -// symmetricDifference returns the symmetric difference between the old (existing) and new (wanted) host ID's. -func symmetricDifference(hostIDs []string, lbInstances []*cloudstack.VirtualMachine) ([]string, []string) { - new := make(map[string]bool) - for _, hostID := range hostIDs { - new[hostID] = true - } - - var remove []string - for _, instance := range lbInstances { - if new[instance.Id] { - delete(new, instance.Id) - continue - } - - remove = append(remove, instance.Id) - } - - var assign []string - for hostID := range new { - assign = append(assign, hostID) - } - - return assign, remove -} diff --git a/pkg/cloudprovider/providers/cloudstack/cloudstack_test.go b/pkg/cloudprovider/providers/cloudstack/cloudstack_test.go deleted file mode 100644 index 2a7b3a2bb8b..00000000000 --- a/pkg/cloudprovider/providers/cloudstack/cloudstack_test.go +++ /dev/null @@ -1,118 +0,0 @@ -/* -Copyright 2016 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package cloudstack - -import ( - "context" - "os" - "strconv" - "strings" - "testing" - - "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -const testClusterName = "testCluster" - -func TestReadConfig(t *testing.T) { - _, err := readConfig(nil) - if err != nil { - t.Fatalf("Should not return an error when no config is provided: %v", err) - } - - cfg, err := readConfig(strings.NewReader(` - [Global] - api-url = https://cloudstack.url - api-key = a-valid-api-key - secret-key = a-valid-secret-key - ssl-no-verify = true - project-id = a-valid-project-id - `)) - if err != nil { - t.Fatalf("Should succeed when a valid config is provided: %v", err) - } - - if cfg.Global.APIURL != "https://cloudstack.url" { - t.Errorf("incorrect api-url: %s", cfg.Global.APIURL) - } - if cfg.Global.APIKey != "a-valid-api-key" { - t.Errorf("incorrect api-key: %s", cfg.Global.APIKey) - } - if cfg.Global.SecretKey != "a-valid-secret-key" { - t.Errorf("incorrect secret-key: %s", cfg.Global.SecretKey) - } - if !cfg.Global.SSLNoVerify { - t.Errorf("incorrect ssl-no-verify: %t", cfg.Global.SSLNoVerify) - } -} - -// This allows acceptance testing against an existing CloudStack environment. -func configFromEnv() (*CSConfig, bool) { - cfg := &CSConfig{} - - cfg.Global.APIURL = os.Getenv("CS_API_URL") - cfg.Global.APIKey = os.Getenv("CS_API_KEY") - cfg.Global.SecretKey = os.Getenv("CS_SECRET_KEY") - cfg.Global.ProjectID = os.Getenv("CS_PROJECT_ID") - - // It is save to ignore the error here. If the input cannot be parsed SSLNoVerify - // will still be a bool with its zero value (false) which is the expected default. - cfg.Global.SSLNoVerify, _ = strconv.ParseBool(os.Getenv("CS_SSL_NO_VERIFY")) - - // Check if we have the minimum required info to be able to connect to CloudStack. - ok := cfg.Global.APIURL != "" && cfg.Global.APIKey != "" && cfg.Global.SecretKey != "" - - return cfg, ok -} - -func TestNewCSCloud(t *testing.T) { - cfg, ok := configFromEnv() - if !ok { - t.Skipf("No config found in environment") - } - - _, err := newCSCloud(cfg) - if err != nil { - t.Fatalf("Failed to construct/authenticate CloudStack: %v", err) - } -} - -func TestLoadBalancer(t *testing.T) { - cfg, ok := configFromEnv() - if !ok { - t.Skipf("No config found in environment") - } - - cs, err := newCSCloud(cfg) - if err != nil { - t.Fatalf("Failed to construct/authenticate CloudStack: %v", err) - } - - lb, ok := cs.LoadBalancer() - if !ok { - t.Fatalf("LoadBalancer() returned false") - } - - _, exists, err := lb.GetLoadBalancer(context.TODO(), testClusterName, &v1.Service{ObjectMeta: metav1.ObjectMeta{Name: "noexist"}}) - if err != nil { - t.Fatalf("GetLoadBalancer(\"noexist\") returned error: %s", err) - } - if exists { - t.Fatalf("GetLoadBalancer(\"noexist\") returned exists") - } -} diff --git a/pkg/cloudprovider/providers/cloudstack/metadata.go b/pkg/cloudprovider/providers/cloudstack/metadata.go deleted file mode 100644 index b666e076dd5..00000000000 --- a/pkg/cloudprovider/providers/cloudstack/metadata.go +++ /dev/null @@ -1,226 +0,0 @@ -/* -Copyright 2016 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package cloudstack - -import ( - "context" - "errors" - "fmt" - "io/ioutil" - "net" - "net/http" - - "github.com/d2g/dhcp4" - "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/types" - cloudprovider "k8s.io/cloud-provider" - "k8s.io/klog" -) - -var _ cloudprovider.Instances = (*metadata)(nil) -var _ cloudprovider.Zones = (*metadata)(nil) - -type metadata struct { - dhcpServer string - zone string -} - -type metadataType string - -const ( - metadataTypeHostname metadataType = "local-hostname" - metadataTypeExternalIP metadataType = "public-ipv4" - metadataTypeInternalIP metadataType = "local-ipv4" - metadataTypeInstanceID metadataType = "instance-id" - metadataTypeInstanceType metadataType = "service-offering" - metadataTypeZone metadataType = "availability-zone" -) - -// NodeAddresses returns the addresses of the specified instance. -func (m *metadata) NodeAddresses(ctx context.Context, name types.NodeName) ([]v1.NodeAddress, error) { - externalIP, err := m.get(metadataTypeExternalIP) - if err != nil { - return nil, fmt.Errorf("could not get external IP: %v", err) - } - - internalIP, err := m.get(metadataTypeInternalIP) - if err != nil { - return nil, fmt.Errorf("could not get internal IP: %v", err) - } - - addresses := []v1.NodeAddress{ - {Type: v1.NodeExternalIP, Address: externalIP}, - {Type: v1.NodeInternalIP, Address: internalIP}, - } - - hostname, err := m.get(metadataTypeHostname) - if err != nil { - return nil, fmt.Errorf("could not get hostname: %v", err) - } - if hostname != "" { - addresses = append(addresses, v1.NodeAddress{Type: v1.NodeHostName, Address: hostname}) - } - - return addresses, nil -} - -// NodeAddressesByProviderID returns the addresses of the specified instance. -func (m *metadata) NodeAddressesByProviderID(ctx context.Context, providerID string) ([]v1.NodeAddress, error) { - return nil, errors.New("NodeAddressesByProviderID not implemented") -} - -// InstanceID returns the cloud provider ID of the specified instance. -func (m *metadata) InstanceID(ctx context.Context, name types.NodeName) (string, error) { - instanceID, err := m.get(metadataTypeInstanceID) - if err != nil { - return "", fmt.Errorf("could not get instance ID: %v", err) - } - - zone, err := m.get(metadataTypeZone) - if err != nil { - return "", fmt.Errorf("could not get zone: %v", err) - } - - return "/" + zone + "/" + instanceID, nil -} - -// InstanceType returns the type of the specified instance. -func (m *metadata) InstanceType(ctx context.Context, name types.NodeName) (string, error) { - instanceType, err := m.get(metadataTypeInstanceType) - if err != nil { - return "", fmt.Errorf("could not get instance type: %v", err) - } - - return instanceType, nil -} - -// InstanceTypeByProviderID returns the type of the specified instance. -func (m *metadata) InstanceTypeByProviderID(ctx context.Context, providerID string) (string, error) { - return "", errors.New("InstanceTypeByProviderID not implemented") -} - -// AddSSHKeyToAllInstances is currently not implemented. -func (m *metadata) AddSSHKeyToAllInstances(ctx context.Context, user string, keyData []byte) error { - return cloudprovider.NotImplemented -} - -// CurrentNodeName returns the name of the node we are currently running on. -func (m *metadata) CurrentNodeName(ctx context.Context, hostname string) (types.NodeName, error) { - return types.NodeName(hostname), nil -} - -// InstanceExistsByProviderID returns if the instance still exists. -func (m *metadata) InstanceExistsByProviderID(ctx context.Context, providerID string) (bool, error) { - return false, errors.New("InstanceExistsByProviderID not implemented") -} - -// InstanceShutdownByProviderID returns if the instance is shutdown. -func (m *metadata) InstanceShutdownByProviderID(ctx context.Context, providerID string) (bool, error) { - return false, cloudprovider.NotImplemented -} - -// GetZone returns the Zone containing the region that the program is running in. -func (m *metadata) GetZone(ctx context.Context) (cloudprovider.Zone, error) { - zone := cloudprovider.Zone{} - - if m.zone == "" { - zoneName, err := m.get(metadataTypeZone) - if err != nil { - return zone, fmt.Errorf("could not get zone: %v", err) - } - - m.zone = zoneName - } - - klog.V(2).Infof("Current zone is %v", zone) - zone.FailureDomain = m.zone - zone.Region = m.zone - - return zone, nil -} - -// GetZoneByProviderID returns the Zone, found by using the provider ID. -func (m *metadata) GetZoneByProviderID(ctx context.Context, providerID string) (cloudprovider.Zone, error) { - return cloudprovider.Zone{}, errors.New("GetZoneByProviderID not implemented") -} - -// GetZoneByNodeName returns the Zone, found by using the node name. -func (m *metadata) GetZoneByNodeName(ctx context.Context, nodeName types.NodeName) (cloudprovider.Zone, error) { - return cloudprovider.Zone{}, errors.New("GetZoneByNodeName not implemented") -} - -func (m *metadata) get(mdType metadataType) (string, error) { - url := fmt.Sprintf("http://%s/latest/meta-data/%s", m.dhcpServer, mdType) - - resp, err := http.Get(url) - if err != nil { - return "", fmt.Errorf("error reading metadata: %v", err) - } - defer resp.Body.Close() - - if resp.StatusCode != http.StatusOK { - return "", fmt.Errorf("unexpected HTTP status: %d", resp.StatusCode) - } - - data, err := ioutil.ReadAll(resp.Body) - if err != nil { - return "", fmt.Errorf("error reading response body: %d", resp.StatusCode) - } - - return string(data), nil -} - -func findDHCPServer() (string, error) { - nics, err := net.Interfaces() - if err != nil { - return "", fmt.Errorf("could not get interfaces: %v", err) - } - - for _, nic := range nics { - if nic.Flags&net.FlagUp == 1 && nic.Flags&net.FlagLoopback == 0 && nic.Flags&net.FlagPointToPoint == 0 { - addrs, err := nic.Addrs() - if err != nil { - return "", fmt.Errorf("error reading IP addresses from interface %v: %v", nic.Name, err) - } - - if addrs != nil { - client, err := newDHCPClient(&nic) - if err != nil { - return "", fmt.Errorf("error creating new DHCP client: %v", err) - } - - discoverPacket, err := client.SendDiscoverPacket() - if err != nil { - return "", fmt.Errorf("error sending DHCP discover package: %v", err) - } - - offerPacket, err := client.GetOffer(&discoverPacket) - if err != nil { - return "", fmt.Errorf("error receiving DHCP offer package: %v", err) - } - - offerPacketOptions := offerPacket.ParseOptions() - - if ipaddr, ok := offerPacketOptions[dhcp4.OptionServerIdentifier]; ok { - return net.IP(ipaddr).String(), nil - } - } - } - } - - return "", errors.New("no server found") -} diff --git a/pkg/cloudprovider/providers/cloudstack/metadata_linux.go b/pkg/cloudprovider/providers/cloudstack/metadata_linux.go deleted file mode 100644 index 02603bf9479..00000000000 --- a/pkg/cloudprovider/providers/cloudstack/metadata_linux.go +++ /dev/null @@ -1,40 +0,0 @@ -// +build linux - -/* -Copyright 2016 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package cloudstack - -import ( - "net" - "time" - - "github.com/d2g/dhcp4client" -) - -func newDHCPClient(nic *net.Interface) (*dhcp4client.Client, error) { - pktsock, err := dhcp4client.NewPacketSock(nic.Index) - if err != nil { - return nil, err - } - - return dhcp4client.New( - dhcp4client.HardwareAddr(nic.HardwareAddr), - dhcp4client.Timeout(2*time.Second), - dhcp4client.Broadcast(false), - dhcp4client.Connection(pktsock), - ) -} diff --git a/pkg/cloudprovider/providers/cloudstack/metadata_other.go b/pkg/cloudprovider/providers/cloudstack/metadata_other.go deleted file mode 100644 index 74a7fe221f3..00000000000 --- a/pkg/cloudprovider/providers/cloudstack/metadata_other.go +++ /dev/null @@ -1,40 +0,0 @@ -// +build !linux - -/* -Copyright 2016 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package cloudstack - -import ( - "net" - "time" - - "github.com/d2g/dhcp4client" -) - -func newDHCPClient(nic *net.Interface) (*dhcp4client.Client, error) { - inetsock, err := dhcp4client.NewInetSock() - if err != nil { - return nil, err - } - - return dhcp4client.New( - dhcp4client.HardwareAddr(nic.HardwareAddr), - dhcp4client.Timeout(2*time.Second), - dhcp4client.Broadcast(false), - dhcp4client.Connection(inetsock), - ) -} diff --git a/pkg/cloudprovider/providers/ovirt/BUILD b/pkg/cloudprovider/providers/ovirt/BUILD deleted file mode 100644 index 4cdbb098800..00000000000 --- a/pkg/cloudprovider/providers/ovirt/BUILD +++ /dev/null @@ -1,39 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -load( - "@io_bazel_rules_go//go:def.bzl", - "go_library", - "go_test", -) - -go_library( - name = "go_default_library", - srcs = ["ovirt.go"], - importpath = "k8s.io/kubernetes/pkg/cloudprovider/providers/ovirt", - deps = [ - "//staging/src/k8s.io/api/core/v1:go_default_library", - "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", - "//staging/src/k8s.io/cloud-provider:go_default_library", - "//vendor/gopkg.in/gcfg.v1:go_default_library", - ], -) - -go_test( - name = "go_default_test", - srcs = ["ovirt_test.go"], - embed = [":go_default_library"], - deps = ["//staging/src/k8s.io/cloud-provider:go_default_library"], -) - -filegroup( - name = "package-srcs", - srcs = glob(["**"]), - tags = ["automanaged"], - visibility = ["//visibility:private"], -) - -filegroup( - name = "all-srcs", - srcs = [":package-srcs"], - tags = ["automanaged"], -) diff --git a/pkg/cloudprovider/providers/ovirt/ovirt.go b/pkg/cloudprovider/providers/ovirt/ovirt.go deleted file mode 100644 index c9364a2585b..00000000000 --- a/pkg/cloudprovider/providers/ovirt/ovirt.go +++ /dev/null @@ -1,329 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package ovirt - -import ( - "context" - "encoding/xml" - "fmt" - "io" - "io/ioutil" - "net" - "net/http" - "net/url" - "path" - "sort" - "strings" - - "gopkg.in/gcfg.v1" - - "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/types" - cloudprovider "k8s.io/cloud-provider" -) - -// ProviderName is the name of this cloud provider. -const ProviderName = "ovirt" - -// Instance specifies UUID, name and IP address of the instance. -type Instance struct { - UUID string - Name string - IPAddress string -} - -// InstanceMap provides the map of Ovirt instances. -type InstanceMap map[string]Instance - -var _ cloudprovider.Interface = (*Cloud)(nil) -var _ cloudprovider.Instances = (*Cloud)(nil) - -// Cloud is an implementation of the cloud provider interface for Ovirt. -type Cloud struct { - VmsRequest *url.URL - HostsRequest *url.URL -} - -// APIConfig wraps the api settings for the Ovirt. -type APIConfig struct { - Connection struct { - APIEntry string `gcfg:"uri"` - Username string `gcfg:"username"` - Password string `gcfg:"password"` - } - Filters struct { - VmsQuery string `gcfg:"vms"` - } -} - -// XMLVMAddress is an implementation for the Ovirt instance IP address in xml. -type XMLVMAddress struct { - Address string `xml:"address,attr"` -} - -// XMLVMInfo is an implementation for the Ovirt instance details in xml. -type XMLVMInfo struct { - UUID string `xml:"id,attr"` - Name string `xml:"name"` - Hostname string `xml:"guest_info>fqdn"` - Addresses []XMLVMAddress `xml:"guest_info>ips>ip"` - State string `xml:"status>state"` -} - -// XMLVmsList is an implementation to provide the list of Ovirt instances. -type XMLVmsList struct { - XMLName xml.Name `xml:"vms"` - VM []XMLVMInfo `xml:"vm"` -} - -func init() { - cloudprovider.RegisterCloudProvider(ProviderName, - func(config io.Reader) (cloudprovider.Interface, error) { - return newOVirtCloud(config) - }) -} - -func newOVirtCloud(config io.Reader) (*Cloud, error) { - if config == nil { - return nil, fmt.Errorf("missing configuration file for ovirt cloud provider") - } - - oVirtConfig := APIConfig{} - - /* defaults */ - oVirtConfig.Connection.Username = "admin@internal" - - if err := gcfg.ReadInto(&oVirtConfig, config); err != nil { - return nil, err - } - - if oVirtConfig.Connection.APIEntry == "" { - return nil, fmt.Errorf("missing ovirt uri in cloud provider configuration") - } - - request, err := url.Parse(oVirtConfig.Connection.APIEntry) - if err != nil { - return nil, err - } - - request.Path = path.Join(request.Path, "vms") - request.User = url.UserPassword(oVirtConfig.Connection.Username, oVirtConfig.Connection.Password) - request.RawQuery = url.Values{"search": {oVirtConfig.Filters.VmsQuery}}.Encode() - - return &Cloud{VmsRequest: request}, nil -} - -// Initialize passes a Kubernetes clientBuilder interface to the cloud provider -func (v *Cloud) Initialize(clientBuilder cloudprovider.ControllerClientBuilder, stop <-chan struct{}) { -} - -// Clusters returns the list of clusters. -func (v *Cloud) Clusters() (cloudprovider.Clusters, bool) { - return nil, false -} - -// ProviderName returns the cloud provider ID. -func (v *Cloud) ProviderName() string { - return ProviderName -} - -// HasClusterID returns true if the cluster has a clusterID -func (v *Cloud) HasClusterID() bool { - return true -} - -// LoadBalancer returns an implementation of LoadBalancer for oVirt cloud -func (v *Cloud) LoadBalancer() (cloudprovider.LoadBalancer, bool) { - return nil, false -} - -// Instances returns an implementation of Instances for oVirt cloud -func (v *Cloud) Instances() (cloudprovider.Instances, bool) { - return v, true -} - -// Zones returns an implementation of Zones for oVirt cloud -func (v *Cloud) Zones() (cloudprovider.Zones, bool) { - return nil, false -} - -// Routes returns an implementation of Routes for oVirt cloud -func (v *Cloud) Routes() (cloudprovider.Routes, bool) { - return nil, false -} - -// NodeAddresses returns the NodeAddresses of the instance with the specified nodeName. -func (v *Cloud) NodeAddresses(ctx context.Context, nodeName types.NodeName) ([]v1.NodeAddress, error) { - name := mapNodeNameToInstanceName(nodeName) - instance, err := v.fetchInstance(name) - if err != nil { - return nil, err - } - - var address net.IP - - if instance.IPAddress != "" { - address = net.ParseIP(instance.IPAddress) - if address == nil { - return nil, fmt.Errorf("couldn't parse address: %s", instance.IPAddress) - } - } else { - resolved, err := net.LookupIP(name) - if err != nil || len(resolved) < 1 { - return nil, fmt.Errorf("couldn't lookup address: %s", name) - } - address = resolved[0] - } - - return []v1.NodeAddress{ - {Type: v1.NodeInternalIP, Address: address.String()}, - {Type: v1.NodeExternalIP, Address: address.String()}, - }, nil -} - -// NodeAddressesByProviderID returns the node addresses of an instances with the specified unique providerID -// This method will not be called from the node that is requesting this ID. i.e. metadata service -// and other local methods cannot be used here -func (v *Cloud) NodeAddressesByProviderID(ctx context.Context, providerID string) ([]v1.NodeAddress, error) { - return []v1.NodeAddress{}, cloudprovider.NotImplemented -} - -// mapNodeNameToInstanceName maps from a k8s NodeName to an ovirt instance name (the hostname) -// This is a simple string cast -func mapNodeNameToInstanceName(nodeName types.NodeName) string { - return string(nodeName) -} - -// InstanceExistsByProviderID returns true if the instance with the given provider id still exists and is running. -// If false is returned with no error, the instance will be immediately deleted by the cloud controller manager. -func (v *Cloud) InstanceExistsByProviderID(ctx context.Context, providerID string) (bool, error) { - return false, cloudprovider.NotImplemented -} - -// InstanceShutdownByProviderID returns true if the instance is in safe state to detach volumes -func (v *Cloud) InstanceShutdownByProviderID(ctx context.Context, providerID string) (bool, error) { - return false, cloudprovider.NotImplemented -} - -// InstanceID returns the cloud provider ID of the node with the specified NodeName. -func (v *Cloud) InstanceID(ctx context.Context, nodeName types.NodeName) (string, error) { - name := mapNodeNameToInstanceName(nodeName) - instance, err := v.fetchInstance(name) - if err != nil { - return "", err - } - // TODO: define a way to identify the provider instance to complete - // the format /. - return "/" + instance.UUID, err -} - -// InstanceTypeByProviderID returns the cloudprovider instance type of the node with the specified unique providerID -// This method will not be called from the node that is requesting this ID. i.e. metadata service -// and other local methods cannot be used here -func (v *Cloud) InstanceTypeByProviderID(ctx context.Context, providerID string) (string, error) { - return "", cloudprovider.NotImplemented -} - -// InstanceType returns the type of the specified instance. -func (v *Cloud) InstanceType(ctx context.Context, name types.NodeName) (string, error) { - return "", nil -} - -func getInstancesFromXML(body io.Reader) (InstanceMap, error) { - if body == nil { - return nil, fmt.Errorf("ovirt rest-api response body is missing") - } - - content, err := ioutil.ReadAll(body) - if err != nil { - return nil, err - } - - vmlist := XMLVmsList{} - - if err := xml.Unmarshal(content, &vmlist); err != nil { - return nil, err - } - - instances := make(InstanceMap) - - for _, vm := range vmlist.VM { - // Always return only vms that are up and running - if vm.Hostname != "" && strings.ToLower(vm.State) == "up" { - address := "" - if len(vm.Addresses) > 0 { - address = vm.Addresses[0].Address - } - - instances[vm.Hostname] = Instance{ - UUID: vm.UUID, - Name: vm.Name, - IPAddress: address, - } - } - } - - return instances, nil -} - -func (v *Cloud) fetchAllInstances() (InstanceMap, error) { - response, err := http.Get(v.VmsRequest.String()) - if err != nil { - return nil, err - } - - defer response.Body.Close() - - return getInstancesFromXML(response.Body) -} - -func (v *Cloud) fetchInstance(name string) (*Instance, error) { - allInstances, err := v.fetchAllInstances() - if err != nil { - return nil, err - } - - instance, found := allInstances[name] - if !found { - return nil, fmt.Errorf("cannot find instance: %s", name) - } - - return &instance, nil -} - -// ListSortedNames returns the list of sorted Ovirt instances name. -func (m *InstanceMap) ListSortedNames() []string { - var names []string - - for k := range *m { - names = append(names, k) - } - - sort.Strings(names) - - return names -} - -// CurrentNodeName is implementation of Instances.CurrentNodeName. -func (v *Cloud) CurrentNodeName(ctx context.Context, hostname string) (types.NodeName, error) { - return types.NodeName(hostname), nil -} - -// AddSSHKeyToAllInstances is currently not implemented. -func (v *Cloud) AddSSHKeyToAllInstances(ctx context.Context, user string, keyData []byte) error { - return cloudprovider.NotImplemented -} diff --git a/pkg/cloudprovider/providers/ovirt/ovirt_test.go b/pkg/cloudprovider/providers/ovirt/ovirt_test.go deleted file mode 100644 index 4ecbe40f6a5..00000000000 --- a/pkg/cloudprovider/providers/ovirt/ovirt_test.go +++ /dev/null @@ -1,126 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package ovirt - -import ( - "io" - "strings" - "testing" - - cloudprovider "k8s.io/cloud-provider" -) - -func TestOVirtCloudConfiguration(t *testing.T) { - config1 := (io.Reader)(nil) - - _, err1 := cloudprovider.GetCloudProvider("ovirt", config1) - if err1 == nil { - t.Fatalf("An error is expected when the configuration is missing") - } - - config2 := strings.NewReader("") - - _, err2 := cloudprovider.GetCloudProvider("ovirt", config2) - if err2 == nil { - t.Fatalf("An error is expected when the configuration is empty") - } - - config3 := strings.NewReader(` -[connection] - `) - - _, err3 := cloudprovider.GetCloudProvider("ovirt", config3) - if err3 == nil { - t.Fatalf("An error is expected when the uri is missing") - } - - config4 := strings.NewReader(` -[connection] -uri = https://localhost:8443/ovirt-engine/api -`) - - _, err4 := cloudprovider.GetCloudProvider("ovirt", config4) - if err4 != nil { - t.Fatalf("Unexpected error creating the provider: %s", err4) - } -} - -func TestOVirtCloudXmlParsing(t *testing.T) { - body1 := (io.Reader)(nil) - - _, err1 := getInstancesFromXML(body1) - if err1 == nil { - t.Fatalf("An error is expected when body is missing") - } - - body2 := strings.NewReader("") - - _, err2 := getInstancesFromXML(body2) - if err2 == nil { - t.Fatalf("An error is expected when body is empty") - } - - body3 := strings.NewReader(` - - - -`) - - instances3, err3 := getInstancesFromXML(body3) - if err3 != nil { - t.Fatalf("Unexpected error listing instances: %s", err3) - } - if len(instances3) > 0 { - t.Fatalf("Unexpected number of instance(s): %d", len(instances3)) - } - - body4 := strings.NewReader(` - - - Up - host1 - - - - - - Up - - - Down - host2 - - - Up - host3 - - -`) - - instances4, err4 := getInstancesFromXML(body4) - if err4 != nil { - t.Fatalf("Unexpected error listing instances: %s", err4) - } - if len(instances4) != 2 { - t.Fatalf("Unexpected number of instance(s): %d", len(instances4)) - } - - names := instances4.ListSortedNames() - if names[0] != "host1" || names[1] != "host3" { - t.Fatalf("Unexpected instance(s): %s", instances4) - } -} diff --git a/pkg/cloudprovider/providers/photon/BUILD b/pkg/cloudprovider/providers/photon/BUILD deleted file mode 100644 index 62a6174993d..00000000000 --- a/pkg/cloudprovider/providers/photon/BUILD +++ /dev/null @@ -1,46 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -load( - "@io_bazel_rules_go//go:def.bzl", - "go_library", - "go_test", -) - -go_library( - name = "go_default_library", - srcs = ["photon.go"], - importpath = "k8s.io/kubernetes/pkg/cloudprovider/providers/photon", - deps = [ - "//staging/src/k8s.io/api/core/v1:go_default_library", - "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", - "//staging/src/k8s.io/cloud-provider:go_default_library", - "//staging/src/k8s.io/cloud-provider/node/helpers:go_default_library", - "//vendor/github.com/vmware/photon-controller-go-sdk/photon:go_default_library", - "//vendor/gopkg.in/gcfg.v1:go_default_library", - "//vendor/k8s.io/klog:go_default_library", - ], -) - -go_test( - name = "go_default_test", - srcs = ["photon_test.go"], - embed = [":go_default_library"], - deps = [ - "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", - "//staging/src/k8s.io/apimachinery/pkg/util/rand:go_default_library", - "//staging/src/k8s.io/cloud-provider:go_default_library", - ], -) - -filegroup( - name = "package-srcs", - srcs = glob(["**"]), - tags = ["automanaged"], - visibility = ["//visibility:private"], -) - -filegroup( - name = "all-srcs", - srcs = [":package-srcs"], - tags = ["automanaged"], -) diff --git a/pkg/cloudprovider/providers/photon/OWNERS b/pkg/cloudprovider/providers/photon/OWNERS deleted file mode 100644 index 36c201edd9a..00000000000 --- a/pkg/cloudprovider/providers/photon/OWNERS +++ /dev/null @@ -1,6 +0,0 @@ -# See the OWNERS docs at https://go.k8s.io/owners - -maintainers: -- luomiao -- kerneltime -- abrarshivani diff --git a/pkg/cloudprovider/providers/photon/photon.go b/pkg/cloudprovider/providers/photon/photon.go deleted file mode 100644 index f3b85e9a145..00000000000 --- a/pkg/cloudprovider/providers/photon/photon.go +++ /dev/null @@ -1,734 +0,0 @@ -/* -Copyright 2016 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// This version of Photon cloud provider supports the disk interface -// for Photon persistent disk volume plugin. LoadBalancer, Routes, and -// Zones are currently not supported. -// The use of Photon cloud provider requires to start kubelet, kube-apiserver, -// and kube-controller-manager with config flag: '--cloud-provider=photon -// --cloud-config=[path_to_config_file]'. When running multi-node kubernetes -// using docker, the config file should be located inside /etc/kubernetes. -package photon - -import ( - "bufio" - "context" - "errors" - "fmt" - "io" - "log" - "net" - "os" - "strings" - - "github.com/vmware/photon-controller-go-sdk/photon" - "gopkg.in/gcfg.v1" - "k8s.io/api/core/v1" - k8stypes "k8s.io/apimachinery/pkg/types" - cloudprovider "k8s.io/cloud-provider" - nodehelpers "k8s.io/cloud-provider/node/helpers" - "k8s.io/klog" -) - -const ( - ProviderName = "photon" - DiskSpecKind = "persistent-disk" - MAC_OUI_VC = "00:50:56" - MAC_OUI_ESX = "00:0c:29" -) - -// overrideIP indicates if the hostname is overridden by IP address, such as when -// running multi-node kubernetes using docker. In this case the user should set -// overrideIP = true in cloud config file. Default value is false. -var overrideIP = false - -var _ cloudprovider.Interface = (*PCCloud)(nil) -var _ cloudprovider.Instances = (*PCCloud)(nil) -var _ cloudprovider.Zones = (*PCCloud)(nil) - -// PCCloud is an implementation of the cloud provider interface for Photon Controller. -type PCCloud struct { - cfg *PCConfig - // InstanceID of the server where this PCCloud object is instantiated. - localInstanceID string - // local $HOSTNAME - localHostname string - // hostname from K8S, could be overridden - localK8sHostname string - // Photon project ID. We assume that there is only one Photon Controller project - // in the environment per current Photon Controller deployment methodology. - projID string - cloudprovider.Zone - photonClient *photon.Client - logger *log.Logger -} - -type PCConfig struct { - Global struct { - // the Photon Controller endpoint IP address - CloudTarget string `gcfg:"target"` - // Photon Controller project name - Project string `gcfg:"project"` - // when kubelet is started with '--hostname-override=${IP_ADDRESS}', set to true; - // otherwise, set to false. - OverrideIP bool `gcfg:"overrideIP"` - // VM ID for this node - VMID string `gcfg:"vmID"` - // Authentication enabled or not - AuthEnabled bool `gcfg:"authentication"` - } -} - -// Disks is interface for manipulation with PhotonController Persistent Disks. -type Disks interface { - // AttachDisk attaches given disk to given node. Current node - // is used when nodeName is empty string. - AttachDisk(ctx context.Context, pdID string, nodeName k8stypes.NodeName) error - - // DetachDisk detaches given disk to given node. Current node - // is used when nodeName is empty string. - DetachDisk(ctx context.Context, pdID string, nodeName k8stypes.NodeName) error - - // DiskIsAttached checks if a disk is attached to the given node. - DiskIsAttached(ctx context.Context, pdID string, nodeName k8stypes.NodeName) (bool, error) - - // DisksAreAttached is a batch function to check if a list of disks are attached - // to the node with the specified NodeName. - DisksAreAttached(ctx context.Context, pdIDs []string, nodeName k8stypes.NodeName) (map[string]bool, error) - - // CreateDisk creates a new PD with given properties. - CreateDisk(volumeOptions *VolumeOptions) (pdID string, err error) - - // DeleteDisk deletes PD. - DeleteDisk(pdID string) error -} - -// VolumeOptions specifies capacity, tags, name and flavorID for a volume. -type VolumeOptions struct { - CapacityGB int - Tags map[string]string - Name string - Flavor string -} - -func readConfig(config io.Reader) (PCConfig, error) { - if config == nil { - err := fmt.Errorf("cloud provider config file is missing. Please restart kubelet with --cloud-provider=photon --cloud-config=[path_to_config_file]") - return PCConfig{}, err - } - - var cfg PCConfig - err := gcfg.ReadInto(&cfg, config) - return cfg, err -} - -func init() { - cloudprovider.RegisterCloudProvider(ProviderName, func(config io.Reader) (cloudprovider.Interface, error) { - cfg, err := readConfig(config) - if err != nil { - klog.Errorf("Photon Cloud Provider: failed to read in cloud provider config file. Error[%v]", err) - return nil, err - } - return newPCCloud(cfg) - }) -} - -// Retrieve the Photon VM ID from the Photon Controller endpoint based on the node name -func getVMIDbyNodename(pc *PCCloud, nodeName string) (string, error) { - photonClient, err := getPhotonClient(pc) - if err != nil { - klog.Errorf("Photon Cloud Provider: Failed to get photon client for getVMIDbyNodename, error: [%v]", err) - return "", err - } - - vmList, err := photonClient.Projects.GetVMs(pc.projID, nil) - if err != nil { - klog.Errorf("Photon Cloud Provider: Failed to GetVMs from project %s with nodeName %s, error: [%v]", pc.projID, nodeName, err) - return "", err - } - - for _, vm := range vmList.Items { - if vm.Name == nodeName { - return vm.ID, nil - } - } - - return "", fmt.Errorf("No matching started VM is found with name %s", nodeName) -} - -// Retrieve the Photon VM ID from the Photon Controller endpoint based on the IP address -func getVMIDbyIP(pc *PCCloud, IPAddress string) (string, error) { - photonClient, err := getPhotonClient(pc) - if err != nil { - klog.Errorf("Photon Cloud Provider: Failed to get photon client for getVMIDbyNodename, error: [%v]", err) - return "", err - } - - vmList, err := photonClient.Projects.GetVMs(pc.projID, nil) - if err != nil { - klog.Errorf("Photon Cloud Provider: Failed to GetVMs for project %s. error: [%v]", pc.projID, err) - return "", err - } - - for _, vm := range vmList.Items { - task, err := photonClient.VMs.GetNetworks(vm.ID) - if err != nil { - klog.Warningf("Photon Cloud Provider: GetNetworks failed for vm.ID %s, error [%v]", vm.ID, err) - } else { - task, err = photonClient.Tasks.Wait(task.ID) - if err != nil { - klog.Warningf("Photon Cloud Provider: Wait task for GetNetworks failed for vm.ID %s, error [%v]", vm.ID, err) - } else { - networkConnections := task.ResourceProperties.(map[string]interface{}) - networks := networkConnections["networkConnections"].([]interface{}) - for _, nt := range networks { - network := nt.(map[string]interface{}) - if val, ok := network["ipAddress"]; ok && val != nil { - ipAddr := val.(string) - if ipAddr == IPAddress { - return vm.ID, nil - } - } - } - } - } - } - - return "", fmt.Errorf("No matching VM is found with IP %s", IPAddress) -} - -func getPhotonClient(pc *PCCloud) (*photon.Client, error) { - var err error - if len(pc.cfg.Global.CloudTarget) == 0 { - return nil, fmt.Errorf("Photon Controller endpoint was not specified") - } - - options := &photon.ClientOptions{ - IgnoreCertificate: true, - } - - pc.photonClient = photon.NewClient(pc.cfg.Global.CloudTarget, options, pc.logger) - if pc.cfg.Global.AuthEnabled == true { - // work around before metadata is available - file, err := os.Open("/etc/kubernetes/pc_login_info") - if err != nil { - klog.Errorf("Photon Cloud Provider: Authentication is enabled but found no username/password at /etc/kubernetes/pc_login_info. Error[%v]", err) - return nil, err - } - defer file.Close() - scanner := bufio.NewScanner(file) - if !scanner.Scan() { - klog.Error("Photon Cloud Provider: Empty username inside /etc/kubernetes/pc_login_info.") - return nil, fmt.Errorf("Failed to create authentication enabled client with invalid username") - } - username := scanner.Text() - if !scanner.Scan() { - klog.Error("Photon Cloud Provider: Empty password set inside /etc/kubernetes/pc_login_info.") - return nil, fmt.Errorf("Failed to create authentication enabled client with invalid password") - } - password := scanner.Text() - - tokenOptions, err := pc.photonClient.Auth.GetTokensByPassword(username, password) - if err != nil { - klog.Error("Photon Cloud Provider: failed to get tokens by password") - return nil, err - } - - options = &photon.ClientOptions{ - IgnoreCertificate: true, - TokenOptions: &photon.TokenOptions{ - AccessToken: tokenOptions.AccessToken, - }, - } - pc.photonClient = photon.NewClient(pc.cfg.Global.CloudTarget, options, pc.logger) - } - - status, err := pc.photonClient.Status.Get() - if err != nil { - klog.Errorf("Photon Cloud Provider: new client creation failed. Error[%v]", err) - return nil, err - } - klog.V(2).Infof("Photon Cloud Provider: Status of the new photon controller client: %v", status) - - return pc.photonClient, nil -} - -func newPCCloud(cfg PCConfig) (*PCCloud, error) { - projID := cfg.Global.Project - vmID := cfg.Global.VMID - - // Get local hostname - hostname, err := os.Hostname() - if err != nil { - klog.Errorf("Photon Cloud Provider: get hostname failed. Error[%v]", err) - return nil, err - } - pc := PCCloud{ - cfg: &cfg, - localInstanceID: vmID, - localHostname: hostname, - localK8sHostname: "", - projID: projID, - } - - overrideIP = cfg.Global.OverrideIP - - return &pc, nil -} - -// Initialize passes a Kubernetes clientBuilder interface to the cloud provider -func (pc *PCCloud) Initialize(clientBuilder cloudprovider.ControllerClientBuilder, stop <-chan struct{}) { -} - -// Instances returns an implementation of Instances for Photon Controller. -func (pc *PCCloud) Instances() (cloudprovider.Instances, bool) { - return pc, true -} - -// List is an implementation of Instances.List. -func (pc *PCCloud) List(filter string) ([]k8stypes.NodeName, error) { - return nil, nil -} - -// NodeAddresses is an implementation of Instances.NodeAddresses. -func (pc *PCCloud) NodeAddresses(ctx context.Context, nodeName k8stypes.NodeName) ([]v1.NodeAddress, error) { - nodeAddrs := []v1.NodeAddress{} - name := string(nodeName) - - if name == pc.localK8sHostname { - ifaces, err := net.Interfaces() - if err != nil { - klog.Errorf("Photon Cloud Provider: net.Interfaces() failed for NodeAddresses. Error[%v]", err) - return nodeAddrs, err - } - - for _, i := range ifaces { - addrs, err := i.Addrs() - if err != nil { - klog.Warningf("Photon Cloud Provider: Failed to extract addresses for NodeAddresses. Error[%v]", err) - } else { - for _, addr := range addrs { - if ipnet, ok := addr.(*net.IPNet); ok && !ipnet.IP.IsLoopback() { - if ipnet.IP.To4() != nil { - // Filter external IP by MAC address OUIs from vCenter and from ESX - if strings.HasPrefix(i.HardwareAddr.String(), MAC_OUI_VC) || - strings.HasPrefix(i.HardwareAddr.String(), MAC_OUI_ESX) { - nodehelpers.AddToNodeAddresses(&nodeAddrs, - v1.NodeAddress{ - Type: v1.NodeExternalIP, - Address: ipnet.IP.String(), - }, - ) - } else { - nodehelpers.AddToNodeAddresses(&nodeAddrs, - v1.NodeAddress{ - Type: v1.NodeInternalIP, - Address: ipnet.IP.String(), - }, - ) - } - } - } - } - } - } - return nodeAddrs, nil - } - - // Inquiring IP addresses from photon controller endpoint only for a node other than this node. - // This is assumed to be done by master only. - vmID, err := getInstanceID(pc, name) - if err != nil { - klog.Errorf("Photon Cloud Provider: getInstanceID failed for NodeAddresses. Error[%v]", err) - return nodeAddrs, err - } - - photonClient, err := getPhotonClient(pc) - if err != nil { - klog.Errorf("Photon Cloud Provider: Failed to get photon client for NodeAddresses, error: [%v]", err) - return nodeAddrs, err - } - - // Retrieve the Photon VM's IP addresses from the Photon Controller endpoint based on the VM ID - vmList, err := photonClient.Projects.GetVMs(pc.projID, nil) - if err != nil { - klog.Errorf("Photon Cloud Provider: Failed to GetVMs for project %s. Error[%v]", pc.projID, err) - return nodeAddrs, err - } - - for _, vm := range vmList.Items { - if vm.ID == vmID { - task, err := photonClient.VMs.GetNetworks(vm.ID) - if err != nil { - klog.Errorf("Photon Cloud Provider: GetNetworks failed for node %s with vm.ID %s. Error[%v]", name, vm.ID, err) - return nodeAddrs, err - } else { - task, err = photonClient.Tasks.Wait(task.ID) - if err != nil { - klog.Errorf("Photon Cloud Provider: Wait task for GetNetworks failed for node %s with vm.ID %s. Error[%v]", name, vm.ID, err) - return nodeAddrs, err - } else { - networkConnections := task.ResourceProperties.(map[string]interface{}) - networks := networkConnections["networkConnections"].([]interface{}) - for _, nt := range networks { - ipAddr := "-" - macAddr := "-" - network := nt.(map[string]interface{}) - if val, ok := network["ipAddress"]; ok && val != nil { - ipAddr = val.(string) - } - if val, ok := network["macAddress"]; ok && val != nil { - macAddr = val.(string) - } - if ipAddr != "-" { - if strings.HasPrefix(macAddr, MAC_OUI_VC) || - strings.HasPrefix(macAddr, MAC_OUI_ESX) { - nodehelpers.AddToNodeAddresses(&nodeAddrs, - v1.NodeAddress{ - Type: v1.NodeExternalIP, - Address: ipAddr, - }, - ) - } else { - nodehelpers.AddToNodeAddresses(&nodeAddrs, - v1.NodeAddress{ - Type: v1.NodeInternalIP, - Address: ipAddr, - }, - ) - } - } - } - return nodeAddrs, nil - } - } - } - } - - klog.Errorf("Failed to find the node %s from Photon Controller endpoint", name) - return nodeAddrs, fmt.Errorf("Failed to find the node %s from Photon Controller endpoint", name) -} - -// NodeAddressesByProviderID returns the node addresses of an instances with the specified unique providerID -// This method will not be called from the node that is requesting this ID. i.e. metadata service -// and other local methods cannot be used here -func (pc *PCCloud) NodeAddressesByProviderID(ctx context.Context, providerID string) ([]v1.NodeAddress, error) { - return []v1.NodeAddress{}, cloudprovider.NotImplemented -} - -func (pc *PCCloud) AddSSHKeyToAllInstances(ctx context.Context, user string, keyData []byte) error { - return cloudprovider.NotImplemented -} - -func (pc *PCCloud) CurrentNodeName(ctx context.Context, hostname string) (k8stypes.NodeName, error) { - pc.localK8sHostname = hostname - return k8stypes.NodeName(hostname), nil -} - -func getInstanceID(pc *PCCloud, name string) (string, error) { - var vmID string - var err error - - if overrideIP == true { - vmID, err = getVMIDbyIP(pc, name) - } else { - vmID, err = getVMIDbyNodename(pc, name) - } - if err != nil { - return "", err - } - - if vmID == "" { - err = cloudprovider.InstanceNotFound - } - - return vmID, err -} - -// InstanceExistsByProviderID returns true if the instance with the given provider id still exists and is running. -// If false is returned with no error, the instance will be immediately deleted by the cloud controller manager. -func (pc *PCCloud) InstanceExistsByProviderID(ctx context.Context, providerID string) (bool, error) { - return false, cloudprovider.NotImplemented -} - -// InstanceShutdownByProviderID returns true if the instance is in safe state to detach volumes -func (pc *PCCloud) InstanceShutdownByProviderID(ctx context.Context, providerID string) (bool, error) { - return false, cloudprovider.NotImplemented -} - -// InstanceID returns the cloud provider ID of the specified instance. -func (pc *PCCloud) InstanceID(ctx context.Context, nodeName k8stypes.NodeName) (string, error) { - name := string(nodeName) - if name == pc.localK8sHostname { - return pc.localInstanceID, nil - } - // We assume only master need to get InstanceID of a node other than itself - id, err := getInstanceID(pc, name) - if err != nil { - klog.Errorf("Photon Cloud Provider: getInstanceID failed for InstanceID. Error[%v]", err) - } - return id, err - -} - -// InstanceTypeByProviderID returns the cloudprovider instance type of the node with the specified unique providerID -// This method will not be called from the node that is requesting this ID. i.e. metadata service -// and other local methods cannot be used here -func (pc *PCCloud) InstanceTypeByProviderID(ctx context.Context, providerID string) (string, error) { - return "", cloudprovider.NotImplemented -} - -func (pc *PCCloud) InstanceType(ctx context.Context, nodeName k8stypes.NodeName) (string, error) { - return "", nil -} - -func (pc *PCCloud) Clusters() (cloudprovider.Clusters, bool) { - return nil, true -} - -// ProviderName returns the cloud provider ID. -func (pc *PCCloud) ProviderName() string { - return ProviderName -} - -// LoadBalancer returns an implementation of LoadBalancer for Photon Controller. -func (pc *PCCloud) LoadBalancer() (cloudprovider.LoadBalancer, bool) { - return nil, false -} - -// Zones returns an implementation of Zones for Photon Controller. -func (pc *PCCloud) Zones() (cloudprovider.Zones, bool) { - return pc, true -} - -func (pc *PCCloud) GetZone(ctx context.Context) (cloudprovider.Zone, error) { - return pc.Zone, nil -} - -// GetZoneByProviderID implements Zones.GetZoneByProviderID -// This is particularly useful in external cloud providers where the kubelet -// does not initialize node data. -func (pc *PCCloud) GetZoneByProviderID(ctx context.Context, providerID string) (cloudprovider.Zone, error) { - return cloudprovider.Zone{}, errors.New("GetZoneByProviderID not implemented") -} - -// GetZoneByNodeName implements Zones.GetZoneByNodeName -// This is particularly useful in external cloud providers where the kubelet -// does not initialize node data. -func (pc *PCCloud) GetZoneByNodeName(ctx context.Context, nodeName k8stypes.NodeName) (cloudprovider.Zone, error) { - return cloudprovider.Zone{}, errors.New("GetZoneByNodeName not imeplemented") -} - -// Routes returns a false since the interface is not supported for photon controller. -func (pc *PCCloud) Routes() (cloudprovider.Routes, bool) { - return nil, false -} - -// HasClusterID returns true if the cluster has a clusterID -func (pc *PCCloud) HasClusterID() bool { - return true -} - -// AttachDisk attaches given virtual disk volume to the compute running kubelet. -func (pc *PCCloud) AttachDisk(ctx context.Context, pdID string, nodeName k8stypes.NodeName) error { - photonClient, err := getPhotonClient(pc) - if err != nil { - klog.Errorf("Photon Cloud Provider: Failed to get photon client for AttachDisk, error: [%v]", err) - return err - } - - operation := &photon.VmDiskOperation{ - DiskID: pdID, - } - - vmID, err := pc.InstanceID(ctx, nodeName) - if err != nil { - klog.Errorf("Photon Cloud Provider: pc.InstanceID failed for AttachDisk. Error[%v]", err) - return err - } - - task, err := photonClient.VMs.AttachDisk(vmID, operation) - if err != nil { - klog.Errorf("Photon Cloud Provider: Failed to attach disk with pdID %s. Error[%v]", pdID, err) - return err - } - - _, err = photonClient.Tasks.Wait(task.ID) - if err != nil { - klog.Errorf("Photon Cloud Provider: Failed to wait for task to attach disk with pdID %s. Error[%v]", pdID, err) - return err - } - - return nil -} - -// Detaches given virtual disk volume from the compute running kubelet. -func (pc *PCCloud) DetachDisk(ctx context.Context, pdID string, nodeName k8stypes.NodeName) error { - photonClient, err := getPhotonClient(pc) - if err != nil { - klog.Errorf("Photon Cloud Provider: Failed to get photon client for DetachDisk, error: [%v]", err) - return err - } - - operation := &photon.VmDiskOperation{ - DiskID: pdID, - } - - vmID, err := pc.InstanceID(ctx, nodeName) - if err != nil { - klog.Errorf("Photon Cloud Provider: pc.InstanceID failed for DetachDisk. Error[%v]", err) - return err - } - - task, err := photonClient.VMs.DetachDisk(vmID, operation) - if err != nil { - klog.Errorf("Photon Cloud Provider: Failed to detach disk with pdID %s. Error[%v]", pdID, err) - return err - } - - _, err = photonClient.Tasks.Wait(task.ID) - if err != nil { - klog.Errorf("Photon Cloud Provider: Failed to wait for task to detach disk with pdID %s. Error[%v]", pdID, err) - return err - } - - return nil -} - -// DiskIsAttached returns if disk is attached to the VM using controllers supported by the plugin. -func (pc *PCCloud) DiskIsAttached(ctx context.Context, pdID string, nodeName k8stypes.NodeName) (bool, error) { - photonClient, err := getPhotonClient(pc) - if err != nil { - klog.Errorf("Photon Cloud Provider: Failed to get photon client for DiskIsAttached, error: [%v]", err) - return false, err - } - - disk, err := photonClient.Disks.Get(pdID) - if err != nil { - klog.Errorf("Photon Cloud Provider: Failed to Get disk with pdID %s. Error[%v]", pdID, err) - return false, err - } - - vmID, err := pc.InstanceID(ctx, nodeName) - if err == cloudprovider.InstanceNotFound { - klog.Infof("Instance %q does not exist, disk %s will be detached automatically.", nodeName, pdID) - return false, nil - } - if err != nil { - klog.Errorf("Photon Cloud Provider: pc.InstanceID failed for DiskIsAttached. Error[%v]", err) - return false, err - } - - for _, vm := range disk.VMs { - if vm == vmID { - return true, nil - } - } - - return false, nil -} - -// DisksAreAttached returns if disks are attached to the VM using controllers supported by the plugin. -func (pc *PCCloud) DisksAreAttached(ctx context.Context, pdIDs []string, nodeName k8stypes.NodeName) (map[string]bool, error) { - attached := make(map[string]bool) - photonClient, err := getPhotonClient(pc) - if err != nil { - klog.Errorf("Photon Cloud Provider: Failed to get photon client for DisksAreAttached, error: [%v]", err) - return attached, err - } - - for _, pdID := range pdIDs { - attached[pdID] = false - } - - vmID, err := pc.InstanceID(ctx, nodeName) - if err == cloudprovider.InstanceNotFound { - klog.Infof("Instance %q does not exist, its disks will be detached automatically.", nodeName) - // make all the disks as detached. - return attached, nil - } - if err != nil { - klog.Errorf("Photon Cloud Provider: pc.InstanceID failed for DiskIsAttached. Error[%v]", err) - return attached, err - } - - for _, pdID := range pdIDs { - disk, err := photonClient.Disks.Get(pdID) - if err != nil { - klog.Warningf("Photon Cloud Provider: failed to get VMs for persistent disk %s, err [%v]", pdID, err) - } else { - for _, vm := range disk.VMs { - if vm == vmID { - attached[pdID] = true - } - } - } - } - - return attached, nil -} - -// Create a volume of given size (in GB). -func (pc *PCCloud) CreateDisk(volumeOptions *VolumeOptions) (pdID string, err error) { - photonClient, err := getPhotonClient(pc) - if err != nil { - klog.Errorf("Photon Cloud Provider: Failed to get photon client for CreateDisk, error: [%v]", err) - return "", err - } - - diskSpec := photon.DiskCreateSpec{} - diskSpec.Name = volumeOptions.Name - diskSpec.Flavor = volumeOptions.Flavor - diskSpec.CapacityGB = volumeOptions.CapacityGB - diskSpec.Kind = DiskSpecKind - - task, err := photonClient.Projects.CreateDisk(pc.projID, &diskSpec) - if err != nil { - klog.Errorf("Photon Cloud Provider: Failed to CreateDisk. Error[%v]", err) - return "", err - } - - waitTask, err := photonClient.Tasks.Wait(task.ID) - if err != nil { - klog.Errorf("Photon Cloud Provider: Failed to wait for task to CreateDisk. Error[%v]", err) - return "", err - } - - return waitTask.Entity.ID, nil -} - -// DeleteDisk deletes a volume given volume name. -func (pc *PCCloud) DeleteDisk(pdID string) error { - photonClient, err := getPhotonClient(pc) - if err != nil { - klog.Errorf("Photon Cloud Provider: Failed to get photon client for DeleteDisk, error: [%v]", err) - return err - } - - task, err := photonClient.Disks.Delete(pdID) - if err != nil { - klog.Errorf("Photon Cloud Provider: Failed to DeleteDisk. Error[%v]", err) - return err - } - - _, err = photonClient.Tasks.Wait(task.ID) - if err != nil { - klog.Errorf("Photon Cloud Provider: Failed to wait for task to DeleteDisk. Error[%v]", err) - return err - } - - return nil -} diff --git a/pkg/cloudprovider/providers/photon/photon_test.go b/pkg/cloudprovider/providers/photon/photon_test.go deleted file mode 100644 index 235eab11bec..00000000000 --- a/pkg/cloudprovider/providers/photon/photon_test.go +++ /dev/null @@ -1,202 +0,0 @@ -/* -Copyright 2016 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package photon - -import ( - "context" - "log" - "os" - "strconv" - "strings" - "testing" - - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/util/rand" - cloudprovider "k8s.io/cloud-provider" -) - -func configFromEnv() (TestVM string, TestFlavor string, cfg PCConfig, ok bool) { - var AuthEnabled bool - var OverrideIP bool - var err error - cfg.Global.CloudTarget = os.Getenv("PHOTON_TARGET") - cfg.Global.Project = os.Getenv("PHOTON_PROJECT") - cfg.Global.VMID = os.Getenv("PHOTON_VMID") - if os.Getenv("PHOTON_AUTH_ENABLED") != "" { - AuthEnabled, err = strconv.ParseBool(os.Getenv("PHOTON_AUTH_ENABLED")) - } else { - AuthEnabled = false - } - if err != nil { - log.Fatal(err) - } - cfg.Global.AuthEnabled = AuthEnabled - if os.Getenv("PHOTON_OVERRIDE_IP") != "" { - OverrideIP, err = strconv.ParseBool(os.Getenv("PHOTON_OVERRIDE_IP")) - } else { - OverrideIP = false - } - if err != nil { - log.Fatal(err) - } - cfg.Global.OverrideIP = OverrideIP - - TestVM = os.Getenv("PHOTON_TEST_VM") - if os.Getenv("PHOTON_TEST_FLAVOR") != "" { - TestFlavor = os.Getenv("PHOTON_TEST_FLAVOR") - } else { - TestFlavor = "" - } - if err != nil { - log.Fatal(err) - } - - ok = (cfg.Global.CloudTarget != "" && - cfg.Global.Project != "" && - cfg.Global.VMID != "" && - TestVM != "") - - return -} - -func TestReadConfig(t *testing.T) { - _, err := readConfig(nil) - if err == nil { - t.Errorf("Should fail when no config is provided: %s", err) - } - - cfg, err := readConfig(strings.NewReader(` -[Global] -target = 0.0.0.0 -project = project -overrideIP = true -vmID = vmid -authentication = false -`)) - if err != nil { - t.Fatalf("Should succeed when a valid config is provided: %s", err) - } - - if cfg.Global.CloudTarget != "0.0.0.0" { - t.Errorf("incorrect photon target ip: %s", cfg.Global.CloudTarget) - } - - if cfg.Global.Project != "project" { - t.Errorf("incorrect project: %s", cfg.Global.Project) - } - - if cfg.Global.VMID != "vmid" { - t.Errorf("incorrect vmid: %s", cfg.Global.VMID) - } -} - -func TestNewPCCloud(t *testing.T) { - _, _, cfg, ok := configFromEnv() - if !ok { - t.Skipf("No config found in environment") - } - - _, err := newPCCloud(cfg) - if err != nil { - t.Fatalf("Failed to create new Photon client: %s", err) - } -} - -func TestInstances(t *testing.T) { - testVM, _, cfg, ok := configFromEnv() - if !ok { - t.Skipf("No config found in environment") - } - NodeName := types.NodeName(testVM) - - pc, err := newPCCloud(cfg) - if err != nil { - t.Fatalf("Failed to create new Photon client: %s", err) - } - - i, ok := pc.Instances() - if !ok { - t.Fatalf("Instances() returned false") - } - - nonExistingVM := types.NodeName(rand.String(15)) - instanceId, err := i.InstanceID(context.TODO(), NodeName) - if err != nil { - t.Fatalf("Instances.InstanceID(%s) failed: %s", testVM, err) - } - t.Logf("Found InstanceID(%s) = %s\n", testVM, instanceId) - - _, err = i.InstanceID(context.TODO(), nonExistingVM) - if err == cloudprovider.InstanceNotFound { - t.Logf("VM %s was not found as expected\n", nonExistingVM) - } else if err == nil { - t.Fatalf("Instances.InstanceID did not fail as expected, VM %s was found", nonExistingVM) - } else { - t.Fatalf("Instances.InstanceID did not fail as expected, err: %v", err) - } - - addrs, err := i.NodeAddresses(context.TODO(), NodeName) - if err != nil { - t.Fatalf("Instances.NodeAddresses(%s) failed: %s", testVM, err) - } - t.Logf("Found NodeAddresses(%s) = %s\n", testVM, addrs) -} - -func TestVolumes(t *testing.T) { - testVM, testFlavor, cfg, ok := configFromEnv() - if !ok { - t.Skipf("No config found in environment") - } - - pc, err := newPCCloud(cfg) - if err != nil { - t.Fatalf("Failed to create new Photon client: %s", err) - } - - NodeName := types.NodeName(testVM) - - volumeOptions := &VolumeOptions{ - CapacityGB: 2, - Tags: nil, - Name: "kubernetes-test-volume-" + rand.String(10), - Flavor: testFlavor} - - pdID, err := pc.CreateDisk(volumeOptions) - if err != nil { - t.Fatalf("Cannot create a Photon persistent disk: %v", err) - } - - err = pc.AttachDisk(context.TODO(), pdID, NodeName) - if err != nil { - t.Fatalf("Cannot attach persistent disk(%s) to VM(%s): %v", pdID, testVM, err) - } - - _, err = pc.DiskIsAttached(context.TODO(), pdID, NodeName) - if err != nil { - t.Fatalf("Cannot attach persistent disk(%s) to VM(%s): %v", pdID, testVM, err) - } - - err = pc.DetachDisk(context.TODO(), pdID, NodeName) - if err != nil { - t.Fatalf("Cannot detach persisten disk(%s) from VM(%s): %v", pdID, testVM, err) - } - - err = pc.DeleteDisk(pdID) - if err != nil { - t.Fatalf("Cannot delete persisten disk(%s): %v", pdID, err) - } -} diff --git a/pkg/cloudprovider/providers/providers.go b/pkg/cloudprovider/providers/providers.go index a93663bf52b..8a5c7c9e815 100644 --- a/pkg/cloudprovider/providers/providers.go +++ b/pkg/cloudprovider/providers/providers.go @@ -18,10 +18,7 @@ package cloudprovider import ( // Cloud providers - _ "k8s.io/kubernetes/pkg/cloudprovider/providers/cloudstack" _ "k8s.io/kubernetes/pkg/cloudprovider/providers/openstack" - _ "k8s.io/kubernetes/pkg/cloudprovider/providers/ovirt" - _ "k8s.io/kubernetes/pkg/cloudprovider/providers/photon" _ "k8s.io/legacy-cloud-providers/aws" _ "k8s.io/legacy-cloud-providers/azure" _ "k8s.io/legacy-cloud-providers/gce" diff --git a/pkg/volume/BUILD b/pkg/volume/BUILD index c5a9f8dda31..3e4c112b507 100644 --- a/pkg/volume/BUILD +++ b/pkg/volume/BUILD @@ -94,7 +94,6 @@ filegroup( "//pkg/volume/iscsi:all-srcs", "//pkg/volume/local:all-srcs", "//pkg/volume/nfs:all-srcs", - "//pkg/volume/photon_pd:all-srcs", "//pkg/volume/portworx:all-srcs", "//pkg/volume/projected:all-srcs", "//pkg/volume/quobyte:all-srcs", diff --git a/pkg/volume/photon_pd/BUILD b/pkg/volume/photon_pd/BUILD deleted file mode 100644 index 4f5ddfbde1a..00000000000 --- a/pkg/volume/photon_pd/BUILD +++ /dev/null @@ -1,63 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -load( - "@io_bazel_rules_go//go:def.bzl", - "go_library", - "go_test", -) - -go_library( - name = "go_default_library", - srcs = [ - "attacher.go", - "photon_pd.go", - "photon_util.go", - ], - importpath = "k8s.io/kubernetes/pkg/volume/photon_pd", - deps = [ - "//pkg/cloudprovider/providers/photon:go_default_library", - "//pkg/util/mount:go_default_library", - "//pkg/volume:go_default_library", - "//pkg/volume/util:go_default_library", - "//staging/src/k8s.io/api/core/v1:go_default_library", - "//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library", - "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", - "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", - "//staging/src/k8s.io/cloud-provider:go_default_library", - "//staging/src/k8s.io/cloud-provider/volume/helpers:go_default_library", - "//vendor/k8s.io/klog:go_default_library", - "//vendor/k8s.io/utils/strings:go_default_library", - ], -) - -go_test( - name = "go_default_test", - srcs = [ - "attacher_test.go", - "photon_pd_test.go", - ], - embed = [":go_default_library"], - deps = [ - "//pkg/cloudprovider/providers/photon:go_default_library", - "//pkg/util/mount:go_default_library", - "//pkg/volume:go_default_library", - "//pkg/volume/testing:go_default_library", - "//staging/src/k8s.io/api/core/v1:go_default_library", - "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", - "//staging/src/k8s.io/client-go/util/testing:go_default_library", - "//vendor/k8s.io/klog:go_default_library", - ], -) - -filegroup( - name = "package-srcs", - srcs = glob(["**"]), - tags = ["automanaged"], - visibility = ["//visibility:private"], -) - -filegroup( - name = "all-srcs", - srcs = [":package-srcs"], - tags = ["automanaged"], -) diff --git a/pkg/volume/photon_pd/OWNERS b/pkg/volume/photon_pd/OWNERS deleted file mode 100644 index 36c201edd9a..00000000000 --- a/pkg/volume/photon_pd/OWNERS +++ /dev/null @@ -1,6 +0,0 @@ -# See the OWNERS docs at https://go.k8s.io/owners - -maintainers: -- luomiao -- kerneltime -- abrarshivani diff --git a/pkg/volume/photon_pd/attacher.go b/pkg/volume/photon_pd/attacher.go deleted file mode 100644 index 60ab3fa5cc7..00000000000 --- a/pkg/volume/photon_pd/attacher.go +++ /dev/null @@ -1,317 +0,0 @@ -/* -Copyright 2016 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package photon_pd - -import ( - "context" - "fmt" - "os" - "path" - "path/filepath" - "strings" - "time" - - "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/types" - "k8s.io/klog" - "k8s.io/kubernetes/pkg/cloudprovider/providers/photon" - "k8s.io/kubernetes/pkg/util/mount" - "k8s.io/kubernetes/pkg/volume" - volumeutil "k8s.io/kubernetes/pkg/volume/util" -) - -type photonPersistentDiskAttacher struct { - host volume.VolumeHost - photonDisks photon.Disks -} - -var _ volume.Attacher = &photonPersistentDiskAttacher{} - -var _ volume.DeviceMounter = &photonPersistentDiskAttacher{} - -var _ volume.AttachableVolumePlugin = &photonPersistentDiskPlugin{} - -var _ volume.DeviceMountableVolumePlugin = &photonPersistentDiskPlugin{} - -func (plugin *photonPersistentDiskPlugin) NewAttacher() (volume.Attacher, error) { - photonCloud, err := getCloudProvider(plugin.host.GetCloudProvider()) - if err != nil { - klog.Errorf("Photon Controller attacher: NewAttacher failed to get cloud provider") - return nil, err - } - - return &photonPersistentDiskAttacher{ - host: plugin.host, - photonDisks: photonCloud, - }, nil -} - -func (plugin *photonPersistentDiskPlugin) NewDeviceMounter() (volume.DeviceMounter, error) { - return plugin.NewAttacher() -} - -// Attaches the volume specified by the given spec to the given host. -// On success, returns the device path where the device was attached on the -// node. -// Callers are responsible for retryinging on failure. -// Callers are responsible for thread safety between concurrent attach and -// detach operations. -func (attacher *photonPersistentDiskAttacher) Attach(spec *volume.Spec, nodeName types.NodeName) (string, error) { - hostName := string(nodeName) - volumeSource, _, err := getVolumeSource(spec) - if err != nil { - klog.Errorf("Photon Controller attacher: Attach failed to get volume source") - return "", err - } - attached, err := attacher.photonDisks.DiskIsAttached(context.TODO(), volumeSource.PdID, nodeName) - - if err != nil { - klog.Warningf("Photon Controller: couldn't check if disk is Attached for host %s, will try attach disk: %+v", hostName, err) - attached = false - } - - if !attached { - klog.V(4).Infof("Photon Controller: Attach disk called for host %s", hostName) - - err = attacher.photonDisks.AttachDisk(context.TODO(), volumeSource.PdID, nodeName) - if err != nil { - klog.Errorf("Error attaching volume %q to node %q: %+v", volumeSource.PdID, nodeName, err) - return "", err - } - } - - PdidWithNoHypens := strings.Replace(volumeSource.PdID, "-", "", -1) - return filepath.Join(diskByIDPath, diskPhotonPrefix+PdidWithNoHypens), nil -} - -func (attacher *photonPersistentDiskAttacher) VolumesAreAttached(specs []*volume.Spec, nodeName types.NodeName) (map[*volume.Spec]bool, error) { - volumesAttachedCheck := make(map[*volume.Spec]bool) - volumeSpecMap := make(map[string]*volume.Spec) - pdIDList := []string{} - for _, spec := range specs { - volumeSource, _, err := getVolumeSource(spec) - if err != nil { - klog.Errorf("Error getting volume (%q) source : %v", spec.Name(), err) - continue - } - - pdIDList = append(pdIDList, volumeSource.PdID) - volumesAttachedCheck[spec] = true - volumeSpecMap[volumeSource.PdID] = spec - } - attachedResult, err := attacher.photonDisks.DisksAreAttached(context.TODO(), pdIDList, nodeName) - if err != nil { - klog.Errorf( - "Error checking if volumes (%v) are attached to current node (%q). err=%v", - pdIDList, nodeName, err) - return volumesAttachedCheck, err - } - - for pdID, attached := range attachedResult { - if !attached { - spec := volumeSpecMap[pdID] - volumesAttachedCheck[spec] = false - klog.V(2).Infof("VolumesAreAttached: check volume %q (specName: %q) is no longer attached", pdID, spec.Name()) - } - } - return volumesAttachedCheck, nil -} - -func (attacher *photonPersistentDiskAttacher) WaitForAttach(spec *volume.Spec, devicePath string, _ *v1.Pod, timeout time.Duration) (string, error) { - volumeSource, _, err := getVolumeSource(spec) - if err != nil { - klog.Errorf("Photon Controller attacher: WaitForAttach failed to get volume source") - return "", err - } - - if devicePath == "" { - return "", fmt.Errorf("WaitForAttach failed for PD %s: devicePath is empty.", volumeSource.PdID) - } - - // scan scsi path to discover the new disk - scsiHostScan() - - ticker := time.NewTicker(checkSleepDuration) - defer ticker.Stop() - - timer := time.NewTimer(timeout) - defer timer.Stop() - - for { - select { - case <-ticker.C: - klog.V(4).Infof("Checking PD %s is attached", volumeSource.PdID) - checkPath, err := verifyDevicePath(devicePath) - if err != nil { - // Log error, if any, and continue checking periodically. See issue #11321 - klog.Warningf("Photon Controller attacher: WaitForAttach with devicePath %s Checking PD %s Error verify path", devicePath, volumeSource.PdID) - } else if checkPath != "" { - // A device path has successfully been created for the VMDK - klog.V(4).Infof("Successfully found attached PD %s.", volumeSource.PdID) - // map path with spec.Name() - volName := spec.Name() - realPath, _ := filepath.EvalSymlinks(devicePath) - deviceName := path.Base(realPath) - volNameToDeviceName[volName] = deviceName - return devicePath, nil - } - case <-timer.C: - return "", fmt.Errorf("Could not find attached PD %s. Timeout waiting for mount paths to be created.", volumeSource.PdID) - } - } -} - -// GetDeviceMountPath returns a path where the device should -// point which should be bind mounted for individual volumes. -func (attacher *photonPersistentDiskAttacher) GetDeviceMountPath(spec *volume.Spec) (string, error) { - volumeSource, _, err := getVolumeSource(spec) - if err != nil { - klog.Errorf("Photon Controller attacher: GetDeviceMountPath failed to get volume source") - return "", err - } - - return makeGlobalPDPath(attacher.host, volumeSource.PdID), nil -} - -// GetMountDeviceRefs finds all other references to the device referenced -// by deviceMountPath; returns a list of paths. -func (plugin *photonPersistentDiskPlugin) GetDeviceMountRefs(deviceMountPath string) ([]string, error) { - mounter := plugin.host.GetMounter(plugin.GetPluginName()) - return mounter.GetMountRefs(deviceMountPath) -} - -// MountDevice mounts device to global mount point. -func (attacher *photonPersistentDiskAttacher) MountDevice(spec *volume.Spec, devicePath string, deviceMountPath string) error { - mounter := attacher.host.GetMounter(photonPersistentDiskPluginName) - notMnt, err := mounter.IsLikelyNotMountPoint(deviceMountPath) - if err != nil { - if os.IsNotExist(err) { - if err := os.MkdirAll(deviceMountPath, 0750); err != nil { - klog.Errorf("Failed to create directory at %#v. err: %s", deviceMountPath, err) - return err - } - notMnt = true - } else { - return err - } - } - - volumeSource, _, err := getVolumeSource(spec) - if err != nil { - klog.Errorf("Photon Controller attacher: MountDevice failed to get volume source. err: %s", err) - return err - } - - options := []string{} - - if notMnt { - diskMounter := volumeutil.NewSafeFormatAndMountFromHost(photonPersistentDiskPluginName, attacher.host) - mountOptions := volumeutil.MountOptionFromSpec(spec) - err = diskMounter.FormatAndMount(devicePath, deviceMountPath, volumeSource.FSType, mountOptions) - if err != nil { - os.Remove(deviceMountPath) - return err - } - klog.V(4).Infof("formatting spec %v devicePath %v deviceMountPath %v fs %v with options %+v", spec.Name(), devicePath, deviceMountPath, volumeSource.FSType, options) - } - return nil -} - -type photonPersistentDiskDetacher struct { - mounter mount.Interface - photonDisks photon.Disks -} - -var _ volume.Detacher = &photonPersistentDiskDetacher{} - -var _ volume.DeviceUnmounter = &photonPersistentDiskDetacher{} - -func (plugin *photonPersistentDiskPlugin) NewDetacher() (volume.Detacher, error) { - photonCloud, err := getCloudProvider(plugin.host.GetCloudProvider()) - if err != nil { - klog.Errorf("Photon Controller attacher: NewDetacher failed to get cloud provider. err: %s", err) - return nil, err - } - - return &photonPersistentDiskDetacher{ - mounter: plugin.host.GetMounter(plugin.GetPluginName()), - photonDisks: photonCloud, - }, nil -} - -func (plugin *photonPersistentDiskPlugin) NewDeviceUnmounter() (volume.DeviceUnmounter, error) { - return plugin.NewDetacher() -} - -// Detach the given device from the given host. -func (detacher *photonPersistentDiskDetacher) Detach(volumeName string, nodeName types.NodeName) error { - - hostName := string(nodeName) - pdID := volumeName - attached, err := detacher.photonDisks.DiskIsAttached(context.TODO(), pdID, nodeName) - if err != nil { - // Log error and continue with detach - klog.Errorf( - "Error checking if persistent disk (%q) is already attached to current node (%q). Will continue and try detach anyway. err=%v", - pdID, hostName, err) - } - - if err == nil && !attached { - // Volume is already detached from node. - klog.V(4).Infof("detach operation was successful. persistent disk %q is already detached from node %q.", pdID, hostName) - return nil - } - - if err := detacher.photonDisks.DetachDisk(context.TODO(), pdID, nodeName); err != nil { - klog.Errorf("Error detaching volume %q: %v", pdID, err) - return err - } - return nil -} - -func (detacher *photonPersistentDiskDetacher) WaitForDetach(devicePath string, timeout time.Duration) error { - ticker := time.NewTicker(checkSleepDuration) - defer ticker.Stop() - timer := time.NewTimer(timeout) - defer timer.Stop() - - for { - select { - case <-ticker.C: - klog.V(4).Infof("Checking device %q is detached.", devicePath) - if pathExists, err := mount.PathExists(devicePath); err != nil { - return fmt.Errorf("Error checking if device path exists: %v", err) - } else if !pathExists { - return nil - } - case <-timer.C: - return fmt.Errorf("Timeout reached; Device %v is still attached", devicePath) - } - } -} - -func (detacher *photonPersistentDiskDetacher) UnmountDevice(deviceMountPath string) error { - return mount.CleanupMountPoint(deviceMountPath, detacher.mounter, false) -} - -func (plugin *photonPersistentDiskPlugin) CanAttach(spec *volume.Spec) (bool, error) { - return true, nil -} - -func (plugin *photonPersistentDiskPlugin) CanDeviceMount(spec *volume.Spec) (bool, error) { - return true, nil -} diff --git a/pkg/volume/photon_pd/attacher_test.go b/pkg/volume/photon_pd/attacher_test.go deleted file mode 100644 index 077131610b5..00000000000 --- a/pkg/volume/photon_pd/attacher_test.go +++ /dev/null @@ -1,330 +0,0 @@ -/* -Copyright 2016 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package photon_pd - -import ( - "context" - "errors" - "testing" - - "k8s.io/api/core/v1" - "k8s.io/kubernetes/pkg/cloudprovider/providers/photon" - "k8s.io/kubernetes/pkg/volume" - volumetest "k8s.io/kubernetes/pkg/volume/testing" - - "k8s.io/apimachinery/pkg/types" - "k8s.io/klog" -) - -func TestGetDeviceName_Volume(t *testing.T) { - plugin := newPlugin() - name := "my-photon-volume" - spec := createVolSpec(name, false) - - deviceName, err := plugin.GetVolumeName(spec) - if err != nil { - t.Errorf("GetDeviceName error: %v", err) - } - if deviceName != name { - t.Errorf("GetDeviceName error: expected %s, got %s", name, deviceName) - } -} - -func TestGetDeviceName_PersistentVolume(t *testing.T) { - plugin := newPlugin() - name := "my-photon-pv" - spec := createPVSpec(name, true) - - deviceName, err := plugin.GetVolumeName(spec) - if err != nil { - t.Errorf("GetDeviceName error: %v", err) - } - if deviceName != name { - t.Errorf("GetDeviceName error: expected %s, got %s", name, deviceName) - } -} - -// One testcase for TestAttachDetach table test below -type testcase struct { - name string - // For fake Photon cloud provider: - attach attachCall - detach detachCall - diskIsAttached diskIsAttachedCall - t *testing.T - - // Actual test to run - test func(test *testcase) (string, error) - // Expected return of the test - expectedDevice string - expectedError error -} - -func TestAttachDetach(t *testing.T) { - diskName := "000-000-000" - nodeName := types.NodeName("instance") - readOnly := false - spec := createVolSpec(diskName, readOnly) - detachError := errors.New("Fake detach error") - diskCheckError := errors.New("Fake DiskIsAttached error") - tests := []testcase{ - // Successful Attach call - { - name: "Attach_Positive", - diskIsAttached: diskIsAttachedCall{diskName, nodeName, false, diskCheckError}, - attach: attachCall{diskName, nodeName, nil}, - test: func(testcase *testcase) (string, error) { - attacher := newAttacher(testcase) - return attacher.Attach(spec, nodeName) - }, - expectedDevice: "/dev/disk/by-id/wwn-0x000000000", - }, - - // Disk is already attached - { - name: "Attach_Positive_AlreadyAttached", - diskIsAttached: diskIsAttachedCall{diskName, nodeName, false, diskCheckError}, - attach: attachCall{diskName, nodeName, nil}, - test: func(testcase *testcase) (string, error) { - attacher := newAttacher(testcase) - return attacher.Attach(spec, nodeName) - }, - expectedDevice: "/dev/disk/by-id/wwn-0x000000000", - }, - - // Detach succeeds - { - name: "Detach_Positive", - diskIsAttached: diskIsAttachedCall{diskName, nodeName, true, nil}, - detach: detachCall{diskName, nodeName, nil}, - test: func(testcase *testcase) (string, error) { - detacher := newDetacher(testcase) - return "", detacher.Detach(diskName, nodeName) - }, - }, - - // Disk is already detached - { - name: "Detach_Positive_AlreadyDetached", - diskIsAttached: diskIsAttachedCall{diskName, nodeName, false, nil}, - test: func(testcase *testcase) (string, error) { - detacher := newDetacher(testcase) - return "", detacher.Detach(diskName, nodeName) - }, - }, - - // Detach succeeds when DiskIsAttached fails - { - name: "Detach_Positive_CheckFails", - diskIsAttached: diskIsAttachedCall{diskName, nodeName, false, diskCheckError}, - detach: detachCall{diskName, nodeName, nil}, - test: func(testcase *testcase) (string, error) { - detacher := newDetacher(testcase) - return "", detacher.Detach(diskName, nodeName) - }, - }, - - // Detach fails - { - name: "Detach_Negative", - diskIsAttached: diskIsAttachedCall{diskName, nodeName, false, diskCheckError}, - detach: detachCall{diskName, nodeName, detachError}, - test: func(testcase *testcase) (string, error) { - detacher := newDetacher(testcase) - return "", detacher.Detach(diskName, nodeName) - }, - expectedError: detachError, - }, - } - - for _, testcase := range tests { - testcase.t = t - device, err := testcase.test(&testcase) - if err != testcase.expectedError { - t.Errorf("%s failed: expected err=%q, got %q", testcase.name, testcase.expectedError.Error(), err.Error()) - } - if device != testcase.expectedDevice { - t.Errorf("%s failed: expected device=%q, got %q", testcase.name, testcase.expectedDevice, device) - } - t.Logf("Test %q succeeded", testcase.name) - } -} - -// newPlugin creates a new gcePersistentDiskPlugin with fake cloud, NewAttacher -// and NewDetacher won't work. -func newPlugin() *photonPersistentDiskPlugin { - host := volumetest.NewFakeVolumeHost("/tmp", nil, nil) - plugins := ProbeVolumePlugins() - plugin := plugins[0] - plugin.Init(host) - return plugin.(*photonPersistentDiskPlugin) -} - -func newAttacher(testcase *testcase) *photonPersistentDiskAttacher { - return &photonPersistentDiskAttacher{ - host: nil, - photonDisks: testcase, - } -} - -func newDetacher(testcase *testcase) *photonPersistentDiskDetacher { - return &photonPersistentDiskDetacher{ - photonDisks: testcase, - } -} - -func createVolSpec(name string, readOnly bool) *volume.Spec { - return &volume.Spec{ - Volume: &v1.Volume{ - VolumeSource: v1.VolumeSource{ - PhotonPersistentDisk: &v1.PhotonPersistentDiskVolumeSource{ - PdID: name, - }, - }, - }, - } -} - -func createPVSpec(name string, readOnly bool) *volume.Spec { - return &volume.Spec{ - PersistentVolume: &v1.PersistentVolume{ - Spec: v1.PersistentVolumeSpec{ - PersistentVolumeSource: v1.PersistentVolumeSource{ - PhotonPersistentDisk: &v1.PhotonPersistentDiskVolumeSource{ - PdID: name, - }, - }, - }, - }, - } -} - -// Fake PhotonPD implementation - -type attachCall struct { - diskName string - nodeName types.NodeName - ret error -} - -type detachCall struct { - diskName string - nodeName types.NodeName - ret error -} - -type diskIsAttachedCall struct { - diskName string - nodeName types.NodeName - isAttached bool - ret error -} - -func (testcase *testcase) AttachDisk(ctx context.Context, diskName string, nodeName types.NodeName) error { - expected := &testcase.attach - - if expected.diskName == "" && expected.nodeName == "" { - // testcase.attach looks uninitialized, test did not expect to call - // AttachDisk - testcase.t.Errorf("Unexpected AttachDisk call!") - return errors.New("Unexpected AttachDisk call!") - } - - if expected.diskName != diskName { - testcase.t.Errorf("Unexpected AttachDisk call: expected diskName %s, got %s", expected.diskName, diskName) - return errors.New("Unexpected AttachDisk call: wrong diskName") - } - - if expected.nodeName != nodeName { - testcase.t.Errorf("Unexpected AttachDisk call: expected nodeName %s, got %s", expected.nodeName, nodeName) - return errors.New("Unexpected AttachDisk call: wrong nodeName") - } - - klog.V(4).Infof("AttachDisk call: %s, %s, returning %v", diskName, nodeName, expected.ret) - - return expected.ret -} - -func (testcase *testcase) DetachDisk(ctx context.Context, diskName string, nodeName types.NodeName) error { - expected := &testcase.detach - - if expected.diskName == "" && expected.nodeName == "" { - // testcase.detach looks uninitialized, test did not expect to call - // DetachDisk - testcase.t.Errorf("Unexpected DetachDisk call!") - return errors.New("Unexpected DetachDisk call!") - } - - if expected.diskName != diskName { - testcase.t.Errorf("Unexpected DetachDisk call: expected diskName %s, got %s", expected.diskName, diskName) - return errors.New("Unexpected DetachDisk call: wrong diskName") - } - - if expected.nodeName != nodeName { - testcase.t.Errorf("Unexpected DetachDisk call: expected nodeName %s, got %s", expected.nodeName, nodeName) - return errors.New("Unexpected DetachDisk call: wrong nodeName") - } - - klog.V(4).Infof("DetachDisk call: %s, %s, returning %v", diskName, nodeName, expected.ret) - - return expected.ret -} - -func (testcase *testcase) DiskIsAttached(ctx context.Context, diskName string, nodeName types.NodeName) (bool, error) { - expected := &testcase.diskIsAttached - - if expected.diskName == "" && expected.nodeName == "" { - // testcase.diskIsAttached looks uninitialized, test did not expect to - // call DiskIsAttached - testcase.t.Errorf("Unexpected DiskIsAttached call!") - return false, errors.New("Unexpected DiskIsAttached call!") - } - - if expected.diskName != diskName { - testcase.t.Errorf("Unexpected DiskIsAttached call: expected diskName %s, got %s", expected.diskName, diskName) - return false, errors.New("Unexpected DiskIsAttached call: wrong diskName") - } - - if expected.nodeName != nodeName { - testcase.t.Errorf("Unexpected DiskIsAttached call: expected nodeName %s, got %s", expected.nodeName, nodeName) - return false, errors.New("Unexpected DiskIsAttached call: wrong nodeName") - } - - klog.V(4).Infof("DiskIsAttached call: %s, %s, returning %v, %v", diskName, nodeName, expected.isAttached, expected.ret) - - return expected.isAttached, expected.ret -} - -func (testcase *testcase) DisksAreAttached(ctx context.Context, diskNames []string, nodeName types.NodeName) (map[string]bool, error) { - return nil, errors.New("Not implemented") -} - -func (testcase *testcase) CreateDisk(volumeOptions *photon.VolumeOptions) (volumeName string, err error) { - return "", errors.New("Not implemented") -} - -func (testcase *testcase) DeleteDisk(volumeName string) error { - return errors.New("Not implemented") -} - -func (testcase *testcase) GetVolumeLabels(volumeName string) (map[string]string, error) { - return map[string]string{}, errors.New("Not implemented") -} - -func (testcase *testcase) GetDiskPath(volumeName string) (string, error) { - return "", errors.New("Not implemented") -} diff --git a/pkg/volume/photon_pd/photon_pd.go b/pkg/volume/photon_pd/photon_pd.go deleted file mode 100644 index 54fe82fa02b..00000000000 --- a/pkg/volume/photon_pd/photon_pd.go +++ /dev/null @@ -1,409 +0,0 @@ -/* -Copyright 2016 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package photon_pd - -import ( - "fmt" - "os" - "path/filepath" - - "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/resource" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/types" - "k8s.io/klog" - "k8s.io/kubernetes/pkg/util/mount" - "k8s.io/kubernetes/pkg/volume" - "k8s.io/kubernetes/pkg/volume/util" - utilstrings "k8s.io/utils/strings" -) - -// This is the primary entrypoint for volume plugins. -func ProbeVolumePlugins() []volume.VolumePlugin { - return []volume.VolumePlugin{&photonPersistentDiskPlugin{}} -} - -type photonPersistentDiskPlugin struct { - host volume.VolumeHost -} - -var _ volume.VolumePlugin = &photonPersistentDiskPlugin{} -var _ volume.PersistentVolumePlugin = &photonPersistentDiskPlugin{} -var _ volume.DeletableVolumePlugin = &photonPersistentDiskPlugin{} -var _ volume.ProvisionableVolumePlugin = &photonPersistentDiskPlugin{} - -const ( - photonPersistentDiskPluginName = "kubernetes.io/photon-pd" -) - -func (plugin *photonPersistentDiskPlugin) Init(host volume.VolumeHost) error { - plugin.host = host - return nil -} - -func (plugin *photonPersistentDiskPlugin) GetPluginName() string { - return photonPersistentDiskPluginName -} - -func (plugin *photonPersistentDiskPlugin) GetVolumeName(spec *volume.Spec) (string, error) { - volumeSource, _, err := getVolumeSource(spec) - if err != nil { - klog.Errorf("Photon volume plugin: GetVolumeName failed to get volume source") - return "", err - } - - return volumeSource.PdID, nil -} - -func (plugin *photonPersistentDiskPlugin) CanSupport(spec *volume.Spec) bool { - return (spec.PersistentVolume != nil && spec.PersistentVolume.Spec.PhotonPersistentDisk != nil) || - (spec.Volume != nil && spec.Volume.PhotonPersistentDisk != nil) -} - -func (plugin *photonPersistentDiskPlugin) IsMigratedToCSI() bool { - return false -} - -func (plugin *photonPersistentDiskPlugin) RequiresRemount() bool { - return false -} - -func (plugin *photonPersistentDiskPlugin) SupportsMountOption() bool { - return true -} - -func (plugin *photonPersistentDiskPlugin) SupportsBulkVolumeVerification() bool { - return false -} - -func (plugin *photonPersistentDiskPlugin) NewMounter(spec *volume.Spec, pod *v1.Pod, _ volume.VolumeOptions) (volume.Mounter, error) { - return plugin.newMounterInternal(spec, pod.UID, &PhotonDiskUtil{}, plugin.host.GetMounter(plugin.GetPluginName())) -} - -func (plugin *photonPersistentDiskPlugin) NewUnmounter(volName string, podUID types.UID) (volume.Unmounter, error) { - return plugin.newUnmounterInternal(volName, podUID, &PhotonDiskUtil{}, plugin.host.GetMounter(plugin.GetPluginName())) -} - -func (plugin *photonPersistentDiskPlugin) newMounterInternal(spec *volume.Spec, podUID types.UID, manager pdManager, mounter mount.Interface) (volume.Mounter, error) { - vvol, _, err := getVolumeSource(spec) - if err != nil { - klog.Errorf("Photon volume plugin: newMounterInternal failed to get volume source") - return nil, err - } - - pdID := vvol.PdID - fsType := vvol.FSType - - return &photonPersistentDiskMounter{ - photonPersistentDisk: &photonPersistentDisk{ - podUID: podUID, - volName: spec.Name(), - pdID: pdID, - manager: manager, - mounter: mounter, - plugin: plugin, - }, - fsType: fsType, - diskMounter: util.NewSafeFormatAndMountFromHost(plugin.GetPluginName(), plugin.host), - mountOption: util.MountOptionFromSpec(spec), - }, nil -} - -func (plugin *photonPersistentDiskPlugin) newUnmounterInternal(volName string, podUID types.UID, manager pdManager, mounter mount.Interface) (volume.Unmounter, error) { - return &photonPersistentDiskUnmounter{ - &photonPersistentDisk{ - podUID: podUID, - volName: volName, - manager: manager, - mounter: mounter, - plugin: plugin, - }}, nil -} - -func (plugin *photonPersistentDiskPlugin) ConstructVolumeSpec(volumeSpecName, mountPath string) (*volume.Spec, error) { - mounter := plugin.host.GetMounter(plugin.GetPluginName()) - pluginMntDir := util.GetPluginMountDir(plugin.host, plugin.GetPluginName()) - pdID, err := mounter.GetDeviceNameFromMount(mountPath, pluginMntDir) - if err != nil { - return nil, err - } - - photonPersistentDisk := &v1.Volume{ - Name: volumeSpecName, - VolumeSource: v1.VolumeSource{ - PhotonPersistentDisk: &v1.PhotonPersistentDiskVolumeSource{ - PdID: pdID, - }, - }, - } - return volume.NewSpecFromVolume(photonPersistentDisk), nil -} - -// Abstract interface to disk operations. -type pdManager interface { - // Creates a volume - CreateVolume(provisioner *photonPersistentDiskProvisioner) (pdID string, volumeSizeGB int, fstype string, err error) - // Deletes a volume - DeleteVolume(deleter *photonPersistentDiskDeleter) error -} - -// photonPersistentDisk volumes are disk resources are attached to the kubelet's host machine and exposed to the pod. -type photonPersistentDisk struct { - volName string - podUID types.UID - // Unique identifier of the volume, used to find the disk resource in the provider. - pdID string - // Filesystem type, optional. - fsType string - // Utility interface that provides API calls to the provider to attach/detach disks. - manager pdManager - // Mounter interface that provides system calls to mount the global path to the pod local path. - mounter mount.Interface - plugin *photonPersistentDiskPlugin - volume.MetricsNil -} - -var _ volume.Mounter = &photonPersistentDiskMounter{} - -type photonPersistentDiskMounter struct { - *photonPersistentDisk - fsType string - diskMounter *mount.SafeFormatAndMount - mountOption []string -} - -func (b *photonPersistentDiskMounter) GetAttributes() volume.Attributes { - return volume.Attributes{ - SupportsSELinux: true, - } -} - -// Checks prior to mount operations to verify that the required components (binaries, etc.) -// to mount the volume are available on the underlying node. -// If not, it returns an error -func (b *photonPersistentDiskMounter) CanMount() error { - return nil -} - -// SetUp attaches the disk and bind mounts to the volume path. -func (b *photonPersistentDiskMounter) SetUp(mounterArgs volume.MounterArgs) error { - return b.SetUpAt(b.GetPath(), mounterArgs) -} - -// SetUp attaches the disk and bind mounts to the volume path. -func (b *photonPersistentDiskMounter) SetUpAt(dir string, mounterArgs volume.MounterArgs) error { - klog.V(4).Infof("Photon Persistent Disk setup %s to %s", b.pdID, dir) - - // TODO: handle failed mounts here. - notmnt, err := b.mounter.IsLikelyNotMountPoint(dir) - if err != nil && !os.IsNotExist(err) { - klog.Errorf("cannot validate mount point: %s %v", dir, err) - return err - } - if !notmnt { - return nil - } - - if err := os.MkdirAll(dir, 0750); err != nil { - klog.Errorf("mkdir failed on disk %s (%v)", dir, err) - return err - } - - options := []string{"bind"} - - // Perform a bind mount to the full path to allow duplicate mounts of the same PD. - globalPDPath := makeGlobalPDPath(b.plugin.host, b.pdID) - klog.V(4).Infof("attempting to mount %s", dir) - - mountOptions := util.JoinMountOptions(options, b.mountOption) - err = b.mounter.Mount(globalPDPath, dir, "", mountOptions) - if err != nil { - notmnt, mntErr := b.mounter.IsLikelyNotMountPoint(dir) - if mntErr != nil { - klog.Errorf("IsLikelyNotMountPoint check failed: %v", mntErr) - return err - } - if !notmnt { - if mntErr = b.mounter.Unmount(dir); mntErr != nil { - klog.Errorf("Failed to unmount: %v", mntErr) - return err - } - notmnt, mntErr := b.mounter.IsLikelyNotMountPoint(dir) - if mntErr != nil { - klog.Errorf("IsLikelyNotMountPoint check failed: %v", mntErr) - return err - } - if !notmnt { - klog.Errorf("%s is still mounted, despite call to unmount(). Will try again next sync loop.", b.GetPath()) - return err - } - } - os.Remove(dir) - klog.Errorf("Mount of disk %s failed: %v", dir, err) - return err - } - - return nil -} - -var _ volume.Unmounter = &photonPersistentDiskUnmounter{} - -type photonPersistentDiskUnmounter struct { - *photonPersistentDisk -} - -// Unmounts the bind mount, and detaches the disk only if the PD -// resource was the last reference to that disk on the kubelet. -func (c *photonPersistentDiskUnmounter) TearDown() error { - err := c.TearDownAt(c.GetPath()) - if err != nil { - return err - } - - removeFromScsiSubsystem(c.volName) - return nil -} - -// Unmounts the bind mount, and detaches the disk only if the PD -// resource was the last reference to that disk on the kubelet. -func (c *photonPersistentDiskUnmounter) TearDownAt(dir string) error { - return mount.CleanupMountPoint(dir, c.mounter, false) -} - -func makeGlobalPDPath(host volume.VolumeHost, devName string) string { - return filepath.Join(host.GetPluginDir(photonPersistentDiskPluginName), util.MountsInGlobalPDPath, devName) -} - -func (ppd *photonPersistentDisk) GetPath() string { - name := photonPersistentDiskPluginName - return ppd.plugin.host.GetPodVolumeDir(ppd.podUID, utilstrings.EscapeQualifiedName(name), ppd.volName) -} - -// TODO: supporting more access mode for PhotonController persistent disk -func (plugin *photonPersistentDiskPlugin) GetAccessModes() []v1.PersistentVolumeAccessMode { - return []v1.PersistentVolumeAccessMode{ - v1.ReadWriteOnce, - } -} - -type photonPersistentDiskDeleter struct { - *photonPersistentDisk -} - -var _ volume.Deleter = &photonPersistentDiskDeleter{} - -func (plugin *photonPersistentDiskPlugin) NewDeleter(spec *volume.Spec) (volume.Deleter, error) { - return plugin.newDeleterInternal(spec, &PhotonDiskUtil{}) -} - -func (plugin *photonPersistentDiskPlugin) newDeleterInternal(spec *volume.Spec, manager pdManager) (volume.Deleter, error) { - if spec.PersistentVolume != nil && spec.PersistentVolume.Spec.PhotonPersistentDisk == nil { - return nil, fmt.Errorf("spec.PersistentVolumeSource.PhotonPersistentDisk is nil") - } - return &photonPersistentDiskDeleter{ - &photonPersistentDisk{ - volName: spec.Name(), - pdID: spec.PersistentVolume.Spec.PhotonPersistentDisk.PdID, - manager: manager, - plugin: plugin, - }}, nil -} - -func (r *photonPersistentDiskDeleter) Delete() error { - return r.manager.DeleteVolume(r) -} - -type photonPersistentDiskProvisioner struct { - *photonPersistentDisk - options volume.VolumeOptions -} - -var _ volume.Provisioner = &photonPersistentDiskProvisioner{} - -func (plugin *photonPersistentDiskPlugin) NewProvisioner(options volume.VolumeOptions) (volume.Provisioner, error) { - return plugin.newProvisionerInternal(options, &PhotonDiskUtil{}) -} - -func (plugin *photonPersistentDiskPlugin) newProvisionerInternal(options volume.VolumeOptions, manager pdManager) (volume.Provisioner, error) { - return &photonPersistentDiskProvisioner{ - photonPersistentDisk: &photonPersistentDisk{ - manager: manager, - plugin: plugin, - }, - options: options, - }, nil -} - -func (p *photonPersistentDiskProvisioner) Provision(selectedNode *v1.Node, allowedTopologies []v1.TopologySelectorTerm) (*v1.PersistentVolume, error) { - if !util.AccessModesContainedInAll(p.plugin.GetAccessModes(), p.options.PVC.Spec.AccessModes) { - return nil, fmt.Errorf("invalid AccessModes %v: only AccessModes %v are supported", p.options.PVC.Spec.AccessModes, p.plugin.GetAccessModes()) - } - - if util.CheckPersistentVolumeClaimModeBlock(p.options.PVC) { - return nil, fmt.Errorf("%s does not support block volume provisioning", p.plugin.GetPluginName()) - } - - pdID, sizeGB, fstype, err := p.manager.CreateVolume(p) - if err != nil { - return nil, err - } - - if fstype == "" { - fstype = "ext4" - } - - pv := &v1.PersistentVolume{ - ObjectMeta: metav1.ObjectMeta{ - Name: p.options.PVName, - Labels: map[string]string{}, - Annotations: map[string]string{ - util.VolumeDynamicallyCreatedByKey: "photon-volume-dynamic-provisioner", - }, - }, - Spec: v1.PersistentVolumeSpec{ - PersistentVolumeReclaimPolicy: p.options.PersistentVolumeReclaimPolicy, - AccessModes: p.options.PVC.Spec.AccessModes, - Capacity: v1.ResourceList{ - v1.ResourceName(v1.ResourceStorage): resource.MustParse(fmt.Sprintf("%dGi", sizeGB)), - }, - PersistentVolumeSource: v1.PersistentVolumeSource{ - PhotonPersistentDisk: &v1.PhotonPersistentDiskVolumeSource{ - PdID: pdID, - FSType: fstype, - }, - }, - MountOptions: p.options.MountOptions, - }, - } - if len(p.options.PVC.Spec.AccessModes) == 0 { - pv.Spec.AccessModes = p.plugin.GetAccessModes() - } - - return pv, nil -} - -func getVolumeSource( - spec *volume.Spec) (*v1.PhotonPersistentDiskVolumeSource, bool, error) { - if spec.Volume != nil && spec.Volume.PhotonPersistentDisk != nil { - return spec.Volume.PhotonPersistentDisk, spec.ReadOnly, nil - } else if spec.PersistentVolume != nil && - spec.PersistentVolume.Spec.PhotonPersistentDisk != nil { - return spec.PersistentVolume.Spec.PhotonPersistentDisk, spec.ReadOnly, nil - } - - return nil, false, fmt.Errorf("Spec does not reference a Photon Controller persistent disk type") -} diff --git a/pkg/volume/photon_pd/photon_pd_test.go b/pkg/volume/photon_pd/photon_pd_test.go deleted file mode 100644 index 8b2beaeb619..00000000000 --- a/pkg/volume/photon_pd/photon_pd_test.go +++ /dev/null @@ -1,235 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package photon_pd - -import ( - "fmt" - "os" - "path/filepath" - "testing" - - "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/types" - utiltesting "k8s.io/client-go/util/testing" - "k8s.io/kubernetes/pkg/util/mount" - "k8s.io/kubernetes/pkg/volume" - volumetest "k8s.io/kubernetes/pkg/volume/testing" -) - -func TestCanSupport(t *testing.T) { - tmpDir, err := utiltesting.MkTmpdir("photonpdTest") - if err != nil { - t.Fatalf("can't make a temp dir: %v", err) - } - defer os.RemoveAll(tmpDir) - plugMgr := volume.VolumePluginMgr{} - plugMgr.InitPlugins(ProbeVolumePlugins(), nil /* prober */, volumetest.NewFakeVolumeHost(tmpDir, nil, nil)) - - plug, err := plugMgr.FindPluginByName("kubernetes.io/photon-pd") - if err != nil { - t.Errorf("Can't find the plugin by name") - } - if plug.GetPluginName() != "kubernetes.io/photon-pd" { - t.Errorf("Wrong name: %s", plug.GetPluginName()) - } - if !plug.CanSupport(&volume.Spec{Volume: &v1.Volume{VolumeSource: v1.VolumeSource{PhotonPersistentDisk: &v1.PhotonPersistentDiskVolumeSource{}}}}) { - t.Errorf("Expected true") - } - if !plug.CanSupport(&volume.Spec{PersistentVolume: &v1.PersistentVolume{Spec: v1.PersistentVolumeSpec{PersistentVolumeSource: v1.PersistentVolumeSource{PhotonPersistentDisk: &v1.PhotonPersistentDiskVolumeSource{}}}}}) { - t.Errorf("Expected true") - } -} - -func TestGetAccessModes(t *testing.T) { - tmpDir, err := utiltesting.MkTmpdir("photonpdTest") - if err != nil { - t.Fatalf("can't make a temp dir: %v", err) - } - defer os.RemoveAll(tmpDir) - plugMgr := volume.VolumePluginMgr{} - plugMgr.InitPlugins(ProbeVolumePlugins(), nil /* prober */, volumetest.NewFakeVolumeHost(tmpDir, nil, nil)) - - plug, err := plugMgr.FindPersistentPluginByName("kubernetes.io/photon-pd") - if err != nil { - t.Errorf("Can't find the plugin by name") - } - - if !volumetest.ContainsAccessMode(plug.GetAccessModes(), v1.ReadWriteOnce) { - t.Errorf("Expected to support AccessModeTypes: %s", v1.ReadWriteOnce) - } - if volumetest.ContainsAccessMode(plug.GetAccessModes(), v1.ReadOnlyMany) { - t.Errorf("Expected not to support AccessModeTypes: %s", v1.ReadOnlyMany) - } -} - -type fakePDManager struct { -} - -func (fake *fakePDManager) CreateVolume(c *photonPersistentDiskProvisioner) (pdID string, volumeSizeGB int, fstype string, err error) { - return "test-photon-pd-id", 10, "ext4", nil -} - -func (fake *fakePDManager) DeleteVolume(cd *photonPersistentDiskDeleter) error { - if cd.pdID != "test-photon-pd-id" { - return fmt.Errorf("Deleter got unexpected volume name: %s", cd.pdID) - } - return nil -} - -func TestPlugin(t *testing.T) { - tmpDir, err := utiltesting.MkTmpdir("photonpdTest") - if err != nil { - t.Fatalf("can't make a temp dir: %v", err) - } - defer os.RemoveAll(tmpDir) - plugMgr := volume.VolumePluginMgr{} - plugMgr.InitPlugins(ProbeVolumePlugins(), nil /* prober */, volumetest.NewFakeVolumeHost(tmpDir, nil, nil)) - - plug, err := plugMgr.FindPluginByName("kubernetes.io/photon-pd") - if err != nil { - t.Errorf("Can't find the plugin by name") - } - spec := &v1.Volume{ - Name: "vol1", - VolumeSource: v1.VolumeSource{ - PhotonPersistentDisk: &v1.PhotonPersistentDiskVolumeSource{ - PdID: "pdid", - FSType: "ext4", - }, - }, - } - fakeManager := &fakePDManager{} - fakeMounter := &mount.FakeMounter{} - mounter, err := plug.(*photonPersistentDiskPlugin).newMounterInternal(volume.NewSpecFromVolume(spec), types.UID("poduid"), fakeManager, fakeMounter) - if err != nil { - t.Errorf("Failed to make a new Mounter: %v", err) - } - if mounter == nil { - t.Errorf("Got a nil Mounter") - } - - volPath := filepath.Join(tmpDir, "pods/poduid/volumes/kubernetes.io~photon-pd/vol1") - path := mounter.GetPath() - if path != volPath { - t.Errorf("Got unexpected path: %s", path) - } - - if err := mounter.SetUp(volume.MounterArgs{}); err != nil { - t.Errorf("Expected success, got: %v", err) - } - if _, err := os.Stat(path); err != nil { - if os.IsNotExist(err) { - t.Errorf("SetUp() failed, volume path not created: %s", path) - } else { - t.Errorf("SetUp() failed: %v", err) - } - } - - fakeManager = &fakePDManager{} - unmounter, err := plug.(*photonPersistentDiskPlugin).newUnmounterInternal("vol1", types.UID("poduid"), fakeManager, fakeMounter) - if err != nil { - t.Errorf("Failed to make a new Unmounter: %v", err) - } - if unmounter == nil { - t.Errorf("Got a nil Unmounter") - } - - if err := unmounter.TearDown(); err != nil { - t.Errorf("Expected success, got: %v", err) - } - if _, err := os.Stat(path); err == nil { - t.Errorf("TearDown() failed, volume path still exists: %s", path) - } else if !os.IsNotExist(err) { - t.Errorf("TearDown() failed: %v", err) - } - - // Test Provisioner - options := volume.VolumeOptions{ - PVC: volumetest.CreateTestPVC("10Gi", []v1.PersistentVolumeAccessMode{v1.ReadWriteOnce}), - PersistentVolumeReclaimPolicy: v1.PersistentVolumeReclaimDelete, - } - provisioner, err := plug.(*photonPersistentDiskPlugin).newProvisionerInternal(options, &fakePDManager{}) - if err != nil { - t.Fatalf("Error creating new provisioner:%v", err) - } - persistentSpec, err := provisioner.Provision(nil, nil) - if err != nil { - t.Errorf("Provision() failed: %v", err) - } - - if persistentSpec.Spec.PersistentVolumeSource.PhotonPersistentDisk.PdID != "test-photon-pd-id" { - t.Errorf("Provision() returned unexpected persistent disk ID: %s", persistentSpec.Spec.PersistentVolumeSource.PhotonPersistentDisk.PdID) - } - cap := persistentSpec.Spec.Capacity[v1.ResourceStorage] - size := cap.Value() - if size != 10*1024*1024*1024 { - t.Errorf("Provision() returned unexpected volume size: %v", size) - } - - // Test Deleter - volSpec := &volume.Spec{ - PersistentVolume: persistentSpec, - } - deleter, err := plug.(*photonPersistentDiskPlugin).newDeleterInternal(volSpec, &fakePDManager{}) - if err != nil { - t.Fatalf("Error creating new deleter:%v", err) - } - err = deleter.Delete() - if err != nil { - t.Errorf("Deleter() failed: %v", err) - } -} - -func TestMounterAndUnmounterTypeAssert(t *testing.T) { - tmpDir, err := utiltesting.MkTmpdir("photonpdTest") - if err != nil { - t.Fatalf("can't make a temp dir: %v", err) - } - defer os.RemoveAll(tmpDir) - plugMgr := volume.VolumePluginMgr{} - plugMgr.InitPlugins(ProbeVolumePlugins(), nil /* prober */, volumetest.NewFakeVolumeHost(tmpDir, nil, nil)) - - plug, err := plugMgr.FindPluginByName("kubernetes.io/photon-pd") - if err != nil { - t.Errorf("Can't find the plugin by name") - } - spec := &v1.Volume{ - Name: "vol1", - VolumeSource: v1.VolumeSource{ - PhotonPersistentDisk: &v1.PhotonPersistentDiskVolumeSource{ - PdID: "pdid", - FSType: "ext4", - }, - }, - } - - mounter, err := plug.(*photonPersistentDiskPlugin).newMounterInternal(volume.NewSpecFromVolume(spec), types.UID("poduid"), &fakePDManager{}, &mount.FakeMounter{}) - if err != nil { - t.Fatalf("Error creating new mounter:%v", err) - } - if _, ok := mounter.(volume.Unmounter); ok { - t.Errorf("Volume Mounter can be type-assert to Unmounter") - } - - unmounter, err := plug.(*photonPersistentDiskPlugin).newUnmounterInternal("vol1", types.UID("poduid"), &fakePDManager{}, &mount.FakeMounter{}) - if err != nil { - t.Fatalf("Error creating new unmounter:%v", err) - } - if _, ok := unmounter.(volume.Mounter); ok { - t.Errorf("Volume Unmounter can be type-assert to Mounter") - } -} diff --git a/pkg/volume/photon_pd/photon_util.go b/pkg/volume/photon_pd/photon_util.go deleted file mode 100644 index b9865d24472..00000000000 --- a/pkg/volume/photon_pd/photon_util.go +++ /dev/null @@ -1,157 +0,0 @@ -/* -Copyright 2016 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package photon_pd - -import ( - "errors" - "fmt" - "io/ioutil" - "strings" - "time" - - "k8s.io/api/core/v1" - cloudprovider "k8s.io/cloud-provider" - volumehelpers "k8s.io/cloud-provider/volume/helpers" - "k8s.io/klog" - "k8s.io/kubernetes/pkg/cloudprovider/providers/photon" - "k8s.io/kubernetes/pkg/util/mount" - "k8s.io/kubernetes/pkg/volume" - volumeutil "k8s.io/kubernetes/pkg/volume/util" -) - -const ( - maxRetries = 10 - checkSleepDuration = time.Second - diskByIDPath = "/dev/disk/by-id/" - diskPhotonPrefix = "wwn-0x" -) - -var ErrProbeVolume = errors.New("Error scanning attached volumes") - -// volNameToDeviceName is a mapping between spec.Name from detacher -// and the device name inside scsi path. Once pvscsi controller is -// supported, this won't be needed. -var volNameToDeviceName = make(map[string]string) - -type PhotonDiskUtil struct{} - -func removeFromScsiSubsystem(volName string) { - // TODO: if using pvscsi controller, this won't be needed - deviceName := volNameToDeviceName[volName] - fileName := "/sys/block/" + deviceName + "/device/delete" - data := []byte("1") - ioutil.WriteFile(fileName, data, 0666) -} - -func scsiHostScan() { - // TODO: if using pvscsi controller, this won't be needed - scsi_path := "/sys/class/scsi_host/" - if dirs, err := ioutil.ReadDir(scsi_path); err == nil { - for _, f := range dirs { - name := scsi_path + f.Name() + "/scan" - data := []byte("- - -") - ioutil.WriteFile(name, data, 0666) - klog.Errorf("scsiHostScan scan for %s", name) - } - } -} - -func verifyDevicePath(path string) (string, error) { - if pathExists, err := mount.PathExists(path); err != nil { - return "", fmt.Errorf("Error checking if path exists: %v", err) - } else if pathExists { - return path, nil - } - - klog.V(4).Infof("verifyDevicePath: path not exists yet") - return "", nil -} - -// CreateVolume creates a PhotonController persistent disk. -func (util *PhotonDiskUtil) CreateVolume(p *photonPersistentDiskProvisioner) (pdID string, capacityGB int, fstype string, err error) { - cloud, err := getCloudProvider(p.plugin.host.GetCloudProvider()) - if err != nil { - klog.Errorf("Photon Controller Util: CreateVolume failed to get cloud provider. Error [%v]", err) - return "", 0, "", err - } - - capacity := p.options.PVC.Spec.Resources.Requests[v1.ResourceName(v1.ResourceStorage)] - // PhotonController works with GiB, convert to GiB with rounding up - volSizeGB, err := volumehelpers.RoundUpToGiBInt(capacity) - if err != nil { - return "", 0, "", err - } - name := volumeutil.GenerateVolumeName(p.options.ClusterName, p.options.PVName, 255) - volumeOptions := &photon.VolumeOptions{ - CapacityGB: volSizeGB, - Tags: *p.options.CloudTags, - Name: name, - } - - for parameter, value := range p.options.Parameters { - switch strings.ToLower(parameter) { - case "flavor": - volumeOptions.Flavor = value - case volume.VolumeParameterFSType: - fstype = value - klog.V(4).Infof("Photon Controller Util: Setting fstype to %s", fstype) - default: - klog.Errorf("Photon Controller Util: invalid option %s for volume plugin %s.", parameter, p.plugin.GetPluginName()) - return "", 0, "", fmt.Errorf("Photon Controller Util: invalid option %s for volume plugin %s.", parameter, p.plugin.GetPluginName()) - } - } - - pdID, err = cloud.CreateDisk(volumeOptions) - if err != nil { - klog.Errorf("Photon Controller Util: failed to CreateDisk. Error [%v]", err) - return "", 0, "", err - } - - klog.V(4).Infof("Successfully created Photon Controller persistent disk %s", name) - return pdID, volSizeGB, "", nil -} - -// DeleteVolume deletes a vSphere volume. -func (util *PhotonDiskUtil) DeleteVolume(pd *photonPersistentDiskDeleter) error { - cloud, err := getCloudProvider(pd.plugin.host.GetCloudProvider()) - if err != nil { - klog.Errorf("Photon Controller Util: DeleteVolume failed to get cloud provider. Error [%v]", err) - return err - } - - if err = cloud.DeleteDisk(pd.pdID); err != nil { - klog.Errorf("Photon Controller Util: failed to DeleteDisk for pdID %s. Error [%v]", pd.pdID, err) - return err - } - - klog.V(4).Infof("Successfully deleted PhotonController persistent disk %s", pd.pdID) - return nil -} - -func getCloudProvider(cloud cloudprovider.Interface) (*photon.PCCloud, error) { - if cloud == nil { - klog.Errorf("Photon Controller Util: Cloud provider not initialized properly") - return nil, fmt.Errorf("Photon Controller Util: Cloud provider not initialized properly") - } - - pcc := cloud.(*photon.PCCloud) - if pcc == nil { - klog.Errorf("Invalid cloud provider: expected Photon Controller") - return nil, fmt.Errorf("Invalid cloud provider: expected Photon Controller") - } - return pcc, nil -} diff --git a/staging/src/k8s.io/cloud-provider/plugins.go b/staging/src/k8s.io/cloud-provider/plugins.go index 9fc6aff8cd2..e8a41d87aac 100644 --- a/staging/src/k8s.io/cloud-provider/plugins.go +++ b/staging/src/k8s.io/cloud-provider/plugins.go @@ -42,11 +42,8 @@ var ( }{ {"aws", false, "The AWS provider is deprecated and will be removed in a future release"}, {"azure", false, "The Azure provider is deprecated and will be removed in a future release"}, - {"cloudstack", false, "The CloudStack Controller project is no longer maintained."}, {"gce", false, "The GCE provider is deprecated and will be removed in a future release"}, {"openstack", true, "https://github.com/kubernetes/cloud-provider-openstack"}, - {"ovirt", false, "The ovirt Controller project is no longer maintained."}, - {"photon", false, "The Photon Controller project is no longer maintained."}, {"vsphere", false, "The vSphere provider is deprecated and will be removed in a future release"}, } ) diff --git a/test/test_owners.csv b/test/test_owners.csv index 8f3d51da648..05d1948f23b 100644 --- a/test/test_owners.csv +++ b/test/test_owners.csv @@ -583,12 +583,8 @@ k8s.io/kubernetes/pkg/client/tests,Q-Lee,1, k8s.io/kubernetes/pkg/client/unversioned,justinsb,1, k8s.io/kubernetes/pkg/cloudprovider/providers/aws,eparis,1, k8s.io/kubernetes/pkg/cloudprovider/providers/azure,saad-ali,1, -k8s.io/kubernetes/pkg/cloudprovider/providers/cloudstack,roberthbailey,1, k8s.io/kubernetes/pkg/cloudprovider/providers/gce,yifan-gu,1, -k8s.io/kubernetes/pkg/cloudprovider/providers/mesos,mml,1, k8s.io/kubernetes/pkg/cloudprovider/providers/openstack,Q-Lee,1, -k8s.io/kubernetes/pkg/cloudprovider/providers/ovirt,dchen1107,1, -k8s.io/kubernetes/pkg/cloudprovider/providers/photon,luomiao,0, k8s.io/kubernetes/pkg/cloudprovider/providers/vsphere,apelisse,1, k8s.io/kubernetes/pkg/controller,mikedanese,1, k8s.io/kubernetes/pkg/controller/bootstrap,mikedanese,0, @@ -821,7 +817,6 @@ k8s.io/kubernetes/pkg/volume/glusterfs,tallclair,1, k8s.io/kubernetes/pkg/volume/hostpath,jbeda,1, k8s.io/kubernetes/pkg/volume/iscsi,cjcullen,1, k8s.io/kubernetes/pkg/volume/nfs,justinsb,1, -k8s.io/kubernetes/pkg/volume/photon_pd,luomiao,0, k8s.io/kubernetes/pkg/volume/projected,kevin-wangzefeng,1, k8s.io/kubernetes/pkg/volume/quobyte,yujuhong,1, k8s.io/kubernetes/pkg/volume/rbd,piosz,1, diff --git a/vendor/BUILD b/vendor/BUILD index 2dacbabff5c..cfdcfe4254b 100644 --- a/vendor/BUILD +++ b/vendor/BUILD @@ -151,8 +151,6 @@ filegroup( "//vendor/github.com/coreos/pkg/dlopen:all-srcs", "//vendor/github.com/cpuguy83/go-md2man/md2man:all-srcs", "//vendor/github.com/cyphar/filepath-securejoin:all-srcs", - "//vendor/github.com/d2g/dhcp4:all-srcs", - "//vendor/github.com/d2g/dhcp4client:all-srcs", "//vendor/github.com/davecgh/go-spew/spew:all-srcs", "//vendor/github.com/daviddengcn/go-colortext:all-srcs", "//vendor/github.com/dgrijalva/jwt-go:all-srcs", @@ -352,9 +350,6 @@ filegroup( "//vendor/github.com/vishvananda/netlink:all-srcs", "//vendor/github.com/vishvananda/netns:all-srcs", "//vendor/github.com/vmware/govmomi:all-srcs", - "//vendor/github.com/vmware/photon-controller-go-sdk/SSPI:all-srcs", - "//vendor/github.com/vmware/photon-controller-go-sdk/photon:all-srcs", - "//vendor/github.com/xanzy/go-cloudstack/cloudstack:all-srcs", "//vendor/github.com/xiang90/probing:all-srcs", "//vendor/go.uber.org/atomic:all-srcs", "//vendor/go.uber.org/multierr:all-srcs", diff --git a/vendor/github.com/d2g/dhcp4/BUILD b/vendor/github.com/d2g/dhcp4/BUILD deleted file mode 100644 index 0086593476e..00000000000 --- a/vendor/github.com/d2g/dhcp4/BUILD +++ /dev/null @@ -1,28 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -go_library( - name = "go_default_library", - srcs = [ - "constants.go", - "helpers.go", - "option.go", - "packet.go", - ], - importmap = "k8s.io/kubernetes/vendor/github.com/d2g/dhcp4", - importpath = "github.com/d2g/dhcp4", - visibility = ["//visibility:public"], -) - -filegroup( - name = "package-srcs", - srcs = glob(["**"]), - tags = ["automanaged"], - visibility = ["//visibility:private"], -) - -filegroup( - name = "all-srcs", - srcs = [":package-srcs"], - tags = ["automanaged"], - visibility = ["//visibility:public"], -) diff --git a/vendor/github.com/d2g/dhcp4/LICENSE b/vendor/github.com/d2g/dhcp4/LICENSE deleted file mode 100644 index f7d058a3586..00000000000 --- a/vendor/github.com/d2g/dhcp4/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2013 Skagerrak Software Limited. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Skagerrak Software Limited nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/vendor/github.com/d2g/dhcp4/README.md b/vendor/github.com/d2g/dhcp4/README.md deleted file mode 100644 index 6752dc71a20..00000000000 --- a/vendor/github.com/d2g/dhcp4/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# DHCP4 - A DHCP library written in Go. - -Warning: This library is still being developed. Function calls will change. - -I've removed Server Functionality, for me this project supports the underlying DHCP format not the implementation. diff --git a/vendor/github.com/d2g/dhcp4/constants.go b/vendor/github.com/d2g/dhcp4/constants.go deleted file mode 100644 index 183a7783713..00000000000 --- a/vendor/github.com/d2g/dhcp4/constants.go +++ /dev/null @@ -1,121 +0,0 @@ -package dhcp4 - -// OpCodes -const ( - BootRequest OpCode = 1 // From Client - BootReply OpCode = 2 // From Server -) - -// DHCP Message Type 53 -const ( - Discover MessageType = 1 // Broadcast Packet From Client - Can I have an IP? - Offer MessageType = 2 // Broadcast From Server - Here's an IP - Request MessageType = 3 // Broadcast From Client - I'll take that IP (Also start for renewals) - Decline MessageType = 4 // Broadcast From Client - Sorry I can't use that IP - ACK MessageType = 5 // From Server, Yes you can have that IP - NAK MessageType = 6 // From Server, No you cannot have that IP - Release MessageType = 7 // From Client, I don't need that IP anymore - Inform MessageType = 8 // From Client, I have this IP and there's nothing you can do about it -) - -// DHCP Options -const ( - End OptionCode = 255 - Pad OptionCode = 0 - OptionSubnetMask OptionCode = 1 - OptionTimeOffset OptionCode = 2 - OptionRouter OptionCode = 3 - OptionTimeServer OptionCode = 4 - OptionNameServer OptionCode = 5 - OptionDomainNameServer OptionCode = 6 - OptionLogServer OptionCode = 7 - OptionCookieServer OptionCode = 8 - OptionLPRServer OptionCode = 9 - OptionImpressServer OptionCode = 10 - OptionResourceLocationServer OptionCode = 11 - OptionHostName OptionCode = 12 - OptionBootFileSize OptionCode = 13 - OptionMeritDumpFile OptionCode = 14 - OptionDomainName OptionCode = 15 - OptionSwapServer OptionCode = 16 - OptionRootPath OptionCode = 17 - OptionExtensionsPath OptionCode = 18 - - // IP Layer Parameters per Host - OptionIPForwardingEnableDisable OptionCode = 19 - OptionNonLocalSourceRoutingEnableDisable OptionCode = 20 - OptionPolicyFilter OptionCode = 21 - OptionMaximumDatagramReassemblySize OptionCode = 22 - OptionDefaultIPTimeToLive OptionCode = 23 - OptionPathMTUAgingTimeout OptionCode = 24 - OptionPathMTUPlateauTable OptionCode = 25 - - // IP Layer Parameters per Interface - OptionInterfaceMTU OptionCode = 26 - OptionAllSubnetsAreLocal OptionCode = 27 - OptionBroadcastAddress OptionCode = 28 - OptionPerformMaskDiscovery OptionCode = 29 - OptionMaskSupplier OptionCode = 30 - OptionPerformRouterDiscovery OptionCode = 31 - OptionRouterSolicitationAddress OptionCode = 32 - OptionStaticRoute OptionCode = 33 - - // Link Layer Parameters per Interface - OptionTrailerEncapsulation OptionCode = 34 - OptionARPCacheTimeout OptionCode = 35 - OptionEthernetEncapsulation OptionCode = 36 - - // TCP Parameters - OptionTCPDefaultTTL OptionCode = 37 - OptionTCPKeepaliveInterval OptionCode = 38 - OptionTCPKeepaliveGarbage OptionCode = 39 - - // Application and Service Parameters - OptionNetworkInformationServiceDomain OptionCode = 40 - OptionNetworkInformationServers OptionCode = 41 - OptionNetworkTimeProtocolServers OptionCode = 42 - OptionVendorSpecificInformation OptionCode = 43 - OptionNetBIOSOverTCPIPNameServer OptionCode = 44 - OptionNetBIOSOverTCPIPDatagramDistributionServer OptionCode = 45 - OptionNetBIOSOverTCPIPNodeType OptionCode = 46 - OptionNetBIOSOverTCPIPScope OptionCode = 47 - OptionXWindowSystemFontServer OptionCode = 48 - OptionXWindowSystemDisplayManager OptionCode = 49 - OptionNetworkInformationServicePlusDomain OptionCode = 64 - OptionNetworkInformationServicePlusServers OptionCode = 65 - OptionMobileIPHomeAgent OptionCode = 68 - OptionSimpleMailTransportProtocol OptionCode = 69 - OptionPostOfficeProtocolServer OptionCode = 70 - OptionNetworkNewsTransportProtocol OptionCode = 71 - OptionDefaultWorldWideWebServer OptionCode = 72 - OptionDefaultFingerServer OptionCode = 73 - OptionDefaultInternetRelayChatServer OptionCode = 74 - OptionStreetTalkServer OptionCode = 75 - OptionStreetTalkDirectoryAssistance OptionCode = 76 - - // DHCP Extensions - OptionRequestedIPAddress OptionCode = 50 - OptionIPAddressLeaseTime OptionCode = 51 - OptionOverload OptionCode = 52 - OptionDHCPMessageType OptionCode = 53 - OptionServerIdentifier OptionCode = 54 - OptionParameterRequestList OptionCode = 55 - OptionMessage OptionCode = 56 - OptionMaximumDHCPMessageSize OptionCode = 57 - OptionRenewalTimeValue OptionCode = 58 - OptionRebindingTimeValue OptionCode = 59 - OptionVendorClassIdentifier OptionCode = 60 - OptionClientIdentifier OptionCode = 61 - - OptionTFTPServerName OptionCode = 66 - OptionBootFileName OptionCode = 67 - - OptionUserClass OptionCode = 77 - - OptionClientArchitecture OptionCode = 93 - - OptionTZPOSIXString OptionCode = 100 - OptionTZDatabaseString OptionCode = 101 - - OptionClasslessRouteFormat OptionCode = 121 -) diff --git a/vendor/github.com/d2g/dhcp4/helpers.go b/vendor/github.com/d2g/dhcp4/helpers.go deleted file mode 100644 index 4b1463869f5..00000000000 --- a/vendor/github.com/d2g/dhcp4/helpers.go +++ /dev/null @@ -1,58 +0,0 @@ -package dhcp4 - -import ( - "encoding/binary" - "net" - "time" -) - -// IPRange returns how many ips in the ip range from start to stop (inclusive) -func IPRange(start, stop net.IP) int { - //return int(Uint([]byte(stop))-Uint([]byte(start))) + 1 - return int(binary.BigEndian.Uint32(stop.To4())) - int(binary.BigEndian.Uint32(start.To4())) + 1 -} - -// IPAdd returns a copy of start + add. -// IPAdd(net.IP{192,168,1,1},30) returns net.IP{192.168.1.31} -func IPAdd(start net.IP, add int) net.IP { // IPv4 only - start = start.To4() - //v := Uvarint([]byte(start)) - result := make(net.IP, 4) - binary.BigEndian.PutUint32(result, binary.BigEndian.Uint32(start)+uint32(add)) - //PutUint([]byte(result), v+uint64(add)) - return result -} - -// IPLess returns where IP a is less than IP b. -func IPLess(a, b net.IP) bool { - b = b.To4() - for i, ai := range a.To4() { - if ai != b[i] { - return ai < b[i] - } - } - return false -} - -// IPInRange returns true if ip is between (inclusive) start and stop. -func IPInRange(start, stop, ip net.IP) bool { - return !(IPLess(ip, start) || IPLess(stop, ip)) -} - -// OptionsLeaseTime - converts a time.Duration to a 4 byte slice, compatible -// with OptionIPAddressLeaseTime. -func OptionsLeaseTime(d time.Duration) []byte { - leaseBytes := make([]byte, 4) - binary.BigEndian.PutUint32(leaseBytes, uint32(d/time.Second)) - //PutUvarint(leaseBytes, uint64(d/time.Second)) - return leaseBytes -} - -// JoinIPs returns a byte slice of IP addresses, one immediately after the other -// This may be useful for creating multiple IP options such as OptionRouter. -func JoinIPs(ips []net.IP) (b []byte) { - for _, v := range ips { - b = append(b, v.To4()...) - } - return -} diff --git a/vendor/github.com/d2g/dhcp4/option.go b/vendor/github.com/d2g/dhcp4/option.go deleted file mode 100644 index fbf86e65cc9..00000000000 --- a/vendor/github.com/d2g/dhcp4/option.go +++ /dev/null @@ -1,40 +0,0 @@ -package dhcp4 - -type OptionCode byte - -type Option struct { - Code OptionCode - Value []byte -} - -// Map of DHCP options -type Options map[OptionCode][]byte - -// SelectOrderOrAll has same functionality as SelectOrder, except if the order -// param is nil, whereby all options are added (in arbitrary order). -func (o Options) SelectOrderOrAll(order []byte) []Option { - if order == nil { - opts := make([]Option, 0, len(o)) - for i, v := range o { - opts = append(opts, Option{Code: i, Value: v}) - } - return opts - } - return o.SelectOrder(order) -} - -// SelectOrder returns a slice of options ordered and selected by a byte array -// usually defined by OptionParameterRequestList. This result is expected to be -// used in ReplyPacket()'s []Option parameter. -func (o Options) SelectOrder(order []byte) []Option { - opts := make([]Option, 0, len(order)) - for _, v := range order { - if data, ok := o[OptionCode(v)]; ok { - opts = append(opts, Option{Code: OptionCode(v), Value: data}) - } - } - return opts -} - -type OpCode byte -type MessageType byte // Option 53 diff --git a/vendor/github.com/d2g/dhcp4/packet.go b/vendor/github.com/d2g/dhcp4/packet.go deleted file mode 100644 index 25d69fb9987..00000000000 --- a/vendor/github.com/d2g/dhcp4/packet.go +++ /dev/null @@ -1,150 +0,0 @@ -package dhcp4 - -import ( - "net" - "time" -) - -// A DHCP packet -type Packet []byte - -func (p Packet) OpCode() OpCode { return OpCode(p[0]) } -func (p Packet) HType() byte { return p[1] } -func (p Packet) HLen() byte { return p[2] } -func (p Packet) Hops() byte { return p[3] } -func (p Packet) XId() []byte { return p[4:8] } -func (p Packet) Secs() []byte { return p[8:10] } // Never Used? -func (p Packet) Flags() []byte { return p[10:12] } -func (p Packet) CIAddr() net.IP { return net.IP(p[12:16]) } -func (p Packet) YIAddr() net.IP { return net.IP(p[16:20]) } -func (p Packet) SIAddr() net.IP { return net.IP(p[20:24]) } -func (p Packet) GIAddr() net.IP { return net.IP(p[24:28]) } -func (p Packet) CHAddr() net.HardwareAddr { - hLen := p.HLen() - if hLen > 16 { // Prevent chaddr exceeding p boundary - hLen = 16 - } - return net.HardwareAddr(p[28 : 28+hLen]) // max endPos 44 -} - -// 192 bytes of zeros BOOTP legacy -func (p Packet) Cookie() []byte { return p[236:240] } -func (p Packet) Options() []byte { - if len(p) > 240 { - return p[240:] - } - return nil -} - -func (p Packet) Broadcast() bool { return p.Flags()[0] > 127 } - -func (p Packet) SetBroadcast(broadcast bool) { - if p.Broadcast() != broadcast { - p.Flags()[0] ^= 128 - } -} - -func (p Packet) SetOpCode(c OpCode) { p[0] = byte(c) } -func (p Packet) SetCHAddr(a net.HardwareAddr) { - copy(p[28:44], a) - p[2] = byte(len(a)) -} -func (p Packet) SetHType(hType byte) { p[1] = hType } -func (p Packet) SetCookie(cookie []byte) { copy(p.Cookie(), cookie) } -func (p Packet) SetHops(hops byte) { p[3] = hops } -func (p Packet) SetXId(xId []byte) { copy(p.XId(), xId) } -func (p Packet) SetSecs(secs []byte) { copy(p.Secs(), secs) } -func (p Packet) SetFlags(flags []byte) { copy(p.Flags(), flags) } -func (p Packet) SetCIAddr(ip net.IP) { copy(p.CIAddr(), ip.To4()) } -func (p Packet) SetYIAddr(ip net.IP) { copy(p.YIAddr(), ip.To4()) } -func (p Packet) SetSIAddr(ip net.IP) { copy(p.SIAddr(), ip.To4()) } -func (p Packet) SetGIAddr(ip net.IP) { copy(p.GIAddr(), ip.To4()) } - -// Parses the packet's options into an Options map -func (p Packet) ParseOptions() Options { - opts := p.Options() - options := make(Options, 10) - for len(opts) >= 2 && OptionCode(opts[0]) != End { - if OptionCode(opts[0]) == Pad { - opts = opts[1:] - continue - } - size := int(opts[1]) - if len(opts) < 2+size { - break - } - options[OptionCode(opts[0])] = opts[2 : 2+size] - opts = opts[2+size:] - } - return options -} - -func NewPacket(opCode OpCode) Packet { - p := make(Packet, 241) - p.SetOpCode(opCode) - p.SetHType(1) // Ethernet - p.SetCookie([]byte{99, 130, 83, 99}) - p[240] = byte(End) - return p -} - -// Appends a DHCP option to the end of a packet -func (p *Packet) AddOption(o OptionCode, value []byte) { - *p = append((*p)[:len(*p)-1], []byte{byte(o), byte(len(value))}...) // Strip off End, Add OptionCode and Length - *p = append(*p, value...) // Add Option Value - *p = append(*p, byte(End)) // Add on new End -} - -// Removes all options from packet. -func (p *Packet) StripOptions() { - *p = append((*p)[:240], byte(End)) -} - -// Creates a request packet that a Client would send to a server. -func RequestPacket(mt MessageType, chAddr net.HardwareAddr, cIAddr net.IP, xId []byte, broadcast bool, options []Option) Packet { - p := NewPacket(BootRequest) - p.SetCHAddr(chAddr) - p.SetXId(xId) - if cIAddr != nil { - p.SetCIAddr(cIAddr) - } - p.SetBroadcast(broadcast) - p.AddOption(OptionDHCPMessageType, []byte{byte(mt)}) - for _, o := range options { - p.AddOption(o.Code, o.Value) - } - p.PadToMinSize() - return p -} - -// ReplyPacket creates a reply packet that a Server would send to a client. -// It uses the req Packet param to copy across common/necessary fields to -// associate the reply the request. -func ReplyPacket(req Packet, mt MessageType, serverId, yIAddr net.IP, leaseDuration time.Duration, options []Option) Packet { - p := NewPacket(BootReply) - p.SetXId(req.XId()) - p.SetFlags(req.Flags()) - p.SetYIAddr(yIAddr) - p.SetGIAddr(req.GIAddr()) - p.SetCHAddr(req.CHAddr()) - p.AddOption(OptionDHCPMessageType, []byte{byte(mt)}) - p.AddOption(OptionServerIdentifier, []byte(serverId)) - if leaseDuration > 0 { - p.AddOption(OptionIPAddressLeaseTime, OptionsLeaseTime(leaseDuration)) - } - for _, o := range options { - p.AddOption(o.Code, o.Value) - } - p.PadToMinSize() - return p -} - -// PadToMinSize pads a packet so that when sent over UDP, the entire packet, -// is 300 bytes (BOOTP min), to be compatible with really old devices. -var padder [272]byte - -func (p *Packet) PadToMinSize() { - if n := len(*p); n < 272 { - *p = append(*p, padder[:272-n]...) - } -} diff --git a/vendor/github.com/d2g/dhcp4client/BUILD b/vendor/github.com/d2g/dhcp4client/BUILD deleted file mode 100644 index e86749074d7..00000000000 --- a/vendor/github.com/d2g/dhcp4client/BUILD +++ /dev/null @@ -1,36 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -go_library( - name = "go_default_library", - srcs = [ - "client.go", - "generatexid.go", - "inetsock.go", - "pktsock_linux.go", - ], - importmap = "k8s.io/kubernetes/vendor/github.com/d2g/dhcp4client", - importpath = "github.com/d2g/dhcp4client", - visibility = ["//visibility:public"], - deps = [ - "//vendor/github.com/d2g/dhcp4:go_default_library", - ] + select({ - "@io_bazel_rules_go//go/platform:linux": [ - "//vendor/golang.org/x/sys/unix:go_default_library", - ], - "//conditions:default": [], - }), -) - -filegroup( - name = "package-srcs", - srcs = glob(["**"]), - tags = ["automanaged"], - visibility = ["//visibility:private"], -) - -filegroup( - name = "all-srcs", - srcs = [":package-srcs"], - tags = ["automanaged"], - visibility = ["//visibility:public"], -) diff --git a/vendor/github.com/d2g/dhcp4client/LICENSE b/vendor/github.com/d2g/dhcp4client/LICENSE deleted file mode 100644 index c33dcc7c928..00000000000 --- a/vendor/github.com/d2g/dhcp4client/LICENSE +++ /dev/null @@ -1,354 +0,0 @@ -Mozilla Public License, version 2.0 - -1. Definitions - -1.1. “Contributor” - - means each individual or legal entity that creates, contributes to the - creation of, or owns Covered Software. - -1.2. “Contributor Version” - - means the combination of the Contributions of others (if any) used by a - Contributor and that particular Contributor’s Contribution. - -1.3. “Contribution” - - means Covered Software of a particular Contributor. - -1.4. “Covered Software” - - means Source Code Form to which the initial Contributor has attached the - notice in Exhibit A, the Executable Form of such Source Code Form, and - Modifications of such Source Code Form, in each case including portions - thereof. - -1.5. “Incompatible With Secondary Licenses” - means - - a. that the initial Contributor has attached the notice described in - Exhibit B to the Covered Software; or - - b. that the Covered Software was made available under the terms of version - 1.1 or earlier of the License, but not also under the terms of a - Secondary License. - -1.6. “Executable Form” - - means any form of the work other than Source Code Form. - -1.7. “Larger Work” - - means a work that combines Covered Software with other material, in a separate - file or files, that is not Covered Software. - -1.8. “License” - - means this document. - -1.9. “Licensable” - - means having the right to grant, to the maximum extent possible, whether at the - time of the initial grant or subsequently, any and all of the rights conveyed by - this License. - -1.10. “Modifications” - - means any of the following: - - a. any file in Source Code Form that results from an addition to, deletion - from, or modification of the contents of Covered Software; or - - b. any new file in Source Code Form that contains any Covered Software. - -1.11. “Patent Claims” of a Contributor - - means any patent claim(s), including without limitation, method, process, - and apparatus claims, in any patent Licensable by such Contributor that - would be infringed, but for the grant of the License, by the making, - using, selling, offering for sale, having made, import, or transfer of - either its Contributions or its Contributor Version. - -1.12. “Secondary License” - - means either the GNU General Public License, Version 2.0, the GNU Lesser - General Public License, Version 2.1, the GNU Affero General Public - License, Version 3.0, or any later versions of those licenses. - -1.13. “Source Code Form” - - means the form of the work preferred for making modifications. - -1.14. “You” (or “Your”) - - means an individual or a legal entity exercising rights under this - License. For legal entities, “You” includes any entity that controls, is - controlled by, or is under common control with You. For purposes of this - definition, “control” means (a) the power, direct or indirect, to cause - the direction or management of such entity, whether by contract or - otherwise, or (b) ownership of more than fifty percent (50%) of the - outstanding shares or beneficial ownership of such entity. - - -2. License Grants and Conditions - -2.1. Grants - - Each Contributor hereby grants You a world-wide, royalty-free, - non-exclusive license: - - a. under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or as - part of a Larger Work; and - - b. under Patent Claims of such Contributor to make, use, sell, offer for - sale, have made, import, and otherwise transfer either its Contributions - or its Contributor Version. - -2.2. Effective Date - - The licenses granted in Section 2.1 with respect to any Contribution become - effective for each Contribution on the date the Contributor first distributes - such Contribution. - -2.3. Limitations on Grant Scope - - The licenses granted in this Section 2 are the only rights granted under this - License. No additional rights or licenses will be implied from the distribution - or licensing of Covered Software under this License. Notwithstanding Section - 2.1(b) above, no patent license is granted by a Contributor: - - a. for any code that a Contributor has removed from Covered Software; or - - b. for infringements caused by: (i) Your and any other third party’s - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - - c. under Patent Claims infringed by Covered Software in the absence of its - Contributions. - - This License does not grant any rights in the trademarks, service marks, or - logos of any Contributor (except as may be necessary to comply with the - notice requirements in Section 3.4). - -2.4. Subsequent Licenses - - No Contributor makes additional grants as a result of Your choice to - distribute the Covered Software under a subsequent version of this License - (see Section 10.2) or under the terms of a Secondary License (if permitted - under the terms of Section 3.3). - -2.5. Representation - - Each Contributor represents that the Contributor believes its Contributions - are its original creation(s) or it has sufficient rights to grant the - rights to its Contributions conveyed by this License. - -2.6. Fair Use - - This License is not intended to limit any rights You have under applicable - copyright doctrines of fair use, fair dealing, or other equivalents. - -2.7. Conditions - - Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in - Section 2.1. - - -3. Responsibilities - -3.1. Distribution of Source Form - - All distribution of Covered Software in Source Code Form, including any - Modifications that You create or to which You contribute, must be under the - terms of this License. You must inform recipients that the Source Code Form - of the Covered Software is governed by the terms of this License, and how - they can obtain a copy of this License. You may not attempt to alter or - restrict the recipients’ rights in the Source Code Form. - -3.2. Distribution of Executable Form - - If You distribute Covered Software in Executable Form then: - - a. such Covered Software must also be made available in Source Code Form, - as described in Section 3.1, and You must inform recipients of the - Executable Form how they can obtain a copy of such Source Code Form by - reasonable means in a timely manner, at a charge no more than the cost - of distribution to the recipient; and - - b. You may distribute such Executable Form under the terms of this License, - or sublicense it under different terms, provided that the license for - the Executable Form does not attempt to limit or alter the recipients’ - rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - - You may create and distribute a Larger Work under terms of Your choice, - provided that You also comply with the requirements of this License for the - Covered Software. If the Larger Work is a combination of Covered Software - with a work governed by one or more Secondary Licenses, and the Covered - Software is not Incompatible With Secondary Licenses, this License permits - You to additionally distribute such Covered Software under the terms of - such Secondary License(s), so that the recipient of the Larger Work may, at - their option, further distribute the Covered Software under the terms of - either this License or such Secondary License(s). - -3.4. Notices - - You may not remove or alter the substance of any license notices (including - copyright notices, patent notices, disclaimers of warranty, or limitations - of liability) contained within the Source Code Form of the Covered - Software, except that You may alter any license notices to the extent - required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - - You may choose to offer, and to charge a fee for, warranty, support, - indemnity or liability obligations to one or more recipients of Covered - Software. However, You may do so only on Your own behalf, and not on behalf - of any Contributor. You must make it absolutely clear that any such - warranty, support, indemnity, or liability obligation is offered by You - alone, and You hereby agree to indemnify every Contributor for any - liability incurred by such Contributor as a result of warranty, support, - indemnity or liability terms You offer. You may include additional - disclaimers of warranty and limitations of liability specific to any - jurisdiction. - -4. Inability to Comply Due to Statute or Regulation - - If it is impossible for You to comply with any of the terms of this License - with respect to some or all of the Covered Software due to statute, judicial - order, or regulation then You must: (a) comply with the terms of this License - to the maximum extent possible; and (b) describe the limitations and the code - they affect. Such description must be placed in a text file included with all - distributions of the Covered Software under this License. Except to the - extent prohibited by statute or regulation, such description must be - sufficiently detailed for a recipient of ordinary skill to be able to - understand it. - -5. Termination - -5.1. The rights granted under this License will terminate automatically if You - fail to comply with any of its terms. However, if You become compliant, - then the rights granted under this License from a particular Contributor - are reinstated (a) provisionally, unless and until such Contributor - explicitly and finally terminates Your grants, and (b) on an ongoing basis, - if such Contributor fails to notify You of the non-compliance by some - reasonable means prior to 60 days after You have come back into compliance. - Moreover, Your grants from a particular Contributor are reinstated on an - ongoing basis if such Contributor notifies You of the non-compliance by - some reasonable means, this is the first time You have received notice of - non-compliance with this License from such Contributor, and You become - compliant prior to 30 days after Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent - infringement claim (excluding declaratory judgment actions, counter-claims, - and cross-claims) alleging that a Contributor Version directly or - indirectly infringes any patent, then the rights granted to You by any and - all Contributors for the Covered Software under Section 2.1 of this License - shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user - license agreements (excluding distributors and resellers) which have been - validly granted by You or Your distributors under this License prior to - termination shall survive termination. - -6. Disclaimer of Warranty - - Covered Software is provided under this License on an “as is” basis, without - warranty of any kind, either expressed, implied, or statutory, including, - without limitation, warranties that the Covered Software is free of defects, - merchantable, fit for a particular purpose or non-infringing. The entire - risk as to the quality and performance of the Covered Software is with You. - Should any Covered Software prove defective in any respect, You (not any - Contributor) assume the cost of any necessary servicing, repair, or - correction. This disclaimer of warranty constitutes an essential part of this - License. No use of any Covered Software is authorized under this License - except under this disclaimer. - -7. Limitation of Liability - - Under no circumstances and under no legal theory, whether tort (including - negligence), contract, or otherwise, shall any Contributor, or anyone who - distributes Covered Software as permitted above, be liable to You for any - direct, indirect, special, incidental, or consequential damages of any - character including, without limitation, damages for lost profits, loss of - goodwill, work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses, even if such party shall have been - informed of the possibility of such damages. This limitation of liability - shall not apply to liability for death or personal injury resulting from such - party’s negligence to the extent applicable law prohibits such limitation. - Some jurisdictions do not allow the exclusion or limitation of incidental or - consequential damages, so this exclusion and limitation may not apply to You. - -8. Litigation - - Any litigation relating to this License may be brought only in the courts of - a jurisdiction where the defendant maintains its principal place of business - and such litigation shall be governed by laws of that jurisdiction, without - reference to its conflict-of-law provisions. Nothing in this Section shall - prevent a party’s ability to bring cross-claims or counter-claims. - -9. Miscellaneous - - This License represents the complete agreement concerning the subject matter - hereof. If any provision of this License is held to be unenforceable, such - provision shall be reformed only to the extent necessary to make it - enforceable. Any law or regulation which provides that the language of a - contract shall be construed against the drafter shall not be used to construe - this License against a Contributor. - - -10. Versions of the License - -10.1. New Versions - - Mozilla Foundation is the license steward. Except as provided in Section - 10.3, no one other than the license steward has the right to modify or - publish new versions of this License. Each version will be given a - distinguishing version number. - -10.2. Effect of New Versions - - You may distribute the Covered Software under the terms of the version of - the License under which You originally received the Covered Software, or - under the terms of any subsequent version published by the license - steward. - -10.3. Modified Versions - - If you create software not governed by this License, and you want to - create a new license for such software, you may create and use a modified - version of this License if you rename the license and remove any - references to the name of the license steward (except to note that such - modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses - If You choose to distribute Source Code Form that is Incompatible With - Secondary Licenses under the terms of this version of the License, the - notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice - - This Source Code Form is subject to the - terms of the Mozilla Public License, v. - 2.0. If a copy of the MPL was not - distributed with this file, You can - obtain one at - http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular file, then -You may include the notice in a location (such as a LICENSE file in a relevant -directory) where a recipient would be likely to look for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - “Incompatible With Secondary Licenses” Notice - - This Source Code Form is “Incompatible - With Secondary Licenses”, as defined by - the Mozilla Public License, v. 2.0. - diff --git a/vendor/github.com/d2g/dhcp4client/README.md b/vendor/github.com/d2g/dhcp4client/README.md deleted file mode 100644 index 785ac2c1dfd..00000000000 --- a/vendor/github.com/d2g/dhcp4client/README.md +++ /dev/null @@ -1,8 +0,0 @@ -dhcp4client [![GoDoc](https://godoc.org/github.com/d2g/dhcp4client?status.svg)](http://godoc.org/github.com/d2g/dhcp4client) [![Coverage Status](https://coveralls.io/repos/d2g/dhcp4client/badge.svg?branch=HEAD)](https://coveralls.io/r/d2g/dhcp4client?branch=HEAD) [![Codeship Status for d2g/dhcp4client](https://codeship.com/projects/d75d9860-b364-0132-bc79-7e1d8cf367b9/status?branch=master)](https://codeship.com/projects/70187) -=========== - -DHCP Client - - -###### Thanks to: -@eyakubovich For AF_PACKET support. diff --git a/vendor/github.com/d2g/dhcp4client/client.go b/vendor/github.com/d2g/dhcp4client/client.go deleted file mode 100644 index ea64c16f51a..00000000000 --- a/vendor/github.com/d2g/dhcp4client/client.go +++ /dev/null @@ -1,364 +0,0 @@ -package dhcp4client - -import ( - "bytes" - "net" - "time" - - "github.com/d2g/dhcp4" -) - -const ( - MaxDHCPLen = 576 -) - -type Client struct { - hardwareAddr net.HardwareAddr //The HardwareAddr to send in the request. - ignoreServers []net.IP //List of Servers to Ignore requests from. - timeout time.Duration //Time before we timeout. - broadcast bool //Set the Bcast flag in BOOTP Flags - connection connection //The Connection Method to use - generateXID func([]byte) //Function Used to Generate a XID -} - -//Abstracts the type of underlying socket used -type connection interface { - Close() error - Write(packet []byte) error - ReadFrom() ([]byte, net.IP, error) - SetReadTimeout(t time.Duration) error -} - -func New(options ...func(*Client) error) (*Client, error) { - c := Client{ - timeout: time.Second * 10, - broadcast: true, - generateXID: CryptoGenerateXID, - } - - err := c.SetOption(options...) - if err != nil { - return nil, err - } - - //if connection hasn't been set as an option create the default. - if c.connection == nil { - conn, err := NewInetSock() - if err != nil { - return nil, err - } - c.connection = conn - } - - return &c, nil -} - -func (c *Client) SetOption(options ...func(*Client) error) error { - for _, opt := range options { - if err := opt(c); err != nil { - return err - } - } - return nil -} - -func Timeout(t time.Duration) func(*Client) error { - return func(c *Client) error { - c.timeout = t - return nil - } -} - -func IgnoreServers(s []net.IP) func(*Client) error { - return func(c *Client) error { - c.ignoreServers = s - return nil - } -} - -func HardwareAddr(h net.HardwareAddr) func(*Client) error { - return func(c *Client) error { - c.hardwareAddr = h - return nil - } -} - -func Broadcast(b bool) func(*Client) error { - return func(c *Client) error { - c.broadcast = b - return nil - } -} - -func Connection(conn connection) func(*Client) error { - return func(c *Client) error { - c.connection = conn - return nil - } -} - -func GenerateXID(g func([]byte)) func(*Client) error { - return func(c *Client) error { - c.generateXID = g - return nil - } -} - -//Close Connections -func (c *Client) Close() error { - if c.connection != nil { - return c.connection.Close() - } - return nil -} - -//Send the Discovery Packet to the Broadcast Channel -func (c *Client) SendDiscoverPacket() (dhcp4.Packet, error) { - discoveryPacket := c.DiscoverPacket() - discoveryPacket.PadToMinSize() - - return discoveryPacket, c.SendPacket(discoveryPacket) -} - -//Retreive Offer... -//Wait for the offer for a specific Discovery Packet. -func (c *Client) GetOffer(discoverPacket *dhcp4.Packet) (dhcp4.Packet, error) { - for { - c.connection.SetReadTimeout(c.timeout) - readBuffer, source, err := c.connection.ReadFrom() - if err != nil { - return dhcp4.Packet{}, err - } - - offerPacket := dhcp4.Packet(readBuffer) - offerPacketOptions := offerPacket.ParseOptions() - - // Ignore Servers in my Ignore list - for _, ignoreServer := range c.ignoreServers { - if source.Equal(ignoreServer) { - continue - } - - if offerPacket.SIAddr().Equal(ignoreServer) { - continue - } - } - - if len(offerPacketOptions[dhcp4.OptionDHCPMessageType]) < 1 || dhcp4.MessageType(offerPacketOptions[dhcp4.OptionDHCPMessageType][0]) != dhcp4.Offer || !bytes.Equal(discoverPacket.XId(), offerPacket.XId()) { - continue - } - - return offerPacket, nil - } - -} - -//Send Request Based On the offer Received. -func (c *Client) SendRequest(offerPacket *dhcp4.Packet) (dhcp4.Packet, error) { - requestPacket := c.RequestPacket(offerPacket) - requestPacket.PadToMinSize() - - return requestPacket, c.SendPacket(requestPacket) -} - -//Retreive Acknowledgement -//Wait for the offer for a specific Request Packet. -func (c *Client) GetAcknowledgement(requestPacket *dhcp4.Packet) (dhcp4.Packet, error) { - for { - c.connection.SetReadTimeout(c.timeout) - readBuffer, source, err := c.connection.ReadFrom() - if err != nil { - return dhcp4.Packet{}, err - } - - acknowledgementPacket := dhcp4.Packet(readBuffer) - acknowledgementPacketOptions := acknowledgementPacket.ParseOptions() - - // Ignore Servers in my Ignore list - for _, ignoreServer := range c.ignoreServers { - if source.Equal(ignoreServer) { - continue - } - - if acknowledgementPacket.SIAddr().Equal(ignoreServer) { - continue - } - } - - if !bytes.Equal(requestPacket.XId(), acknowledgementPacket.XId()) || len(acknowledgementPacketOptions[dhcp4.OptionDHCPMessageType]) < 1 || (dhcp4.MessageType(acknowledgementPacketOptions[dhcp4.OptionDHCPMessageType][0]) != dhcp4.ACK && dhcp4.MessageType(acknowledgementPacketOptions[dhcp4.OptionDHCPMessageType][0]) != dhcp4.NAK) { - continue - } - - return acknowledgementPacket, nil - } -} - -//Send Decline to the received acknowledgement. -func (c *Client) SendDecline(acknowledgementPacket *dhcp4.Packet) (dhcp4.Packet, error) { - declinePacket := c.DeclinePacket(acknowledgementPacket) - declinePacket.PadToMinSize() - - return declinePacket, c.SendPacket(declinePacket) -} - -//Send a DHCP Packet. -func (c *Client) SendPacket(packet dhcp4.Packet) error { - return c.connection.Write(packet) -} - -//Create Discover Packet -func (c *Client) DiscoverPacket() dhcp4.Packet { - messageid := make([]byte, 4) - c.generateXID(messageid) - - packet := dhcp4.NewPacket(dhcp4.BootRequest) - packet.SetCHAddr(c.hardwareAddr) - packet.SetXId(messageid) - packet.SetBroadcast(c.broadcast) - - packet.AddOption(dhcp4.OptionDHCPMessageType, []byte{byte(dhcp4.Discover)}) - //packet.PadToMinSize() - return packet -} - -//Create Request Packet -func (c *Client) RequestPacket(offerPacket *dhcp4.Packet) dhcp4.Packet { - offerOptions := offerPacket.ParseOptions() - - packet := dhcp4.NewPacket(dhcp4.BootRequest) - packet.SetCHAddr(c.hardwareAddr) - - packet.SetXId(offerPacket.XId()) - packet.SetCIAddr(offerPacket.CIAddr()) - packet.SetSIAddr(offerPacket.SIAddr()) - - packet.SetBroadcast(c.broadcast) - packet.AddOption(dhcp4.OptionDHCPMessageType, []byte{byte(dhcp4.Request)}) - packet.AddOption(dhcp4.OptionRequestedIPAddress, (offerPacket.YIAddr()).To4()) - packet.AddOption(dhcp4.OptionServerIdentifier, offerOptions[dhcp4.OptionServerIdentifier]) - - return packet -} - -//Create Request Packet For a Renew -func (c *Client) RenewalRequestPacket(acknowledgement *dhcp4.Packet) dhcp4.Packet { - messageid := make([]byte, 4) - c.generateXID(messageid) - - acknowledgementOptions := acknowledgement.ParseOptions() - - packet := dhcp4.NewPacket(dhcp4.BootRequest) - packet.SetCHAddr(acknowledgement.CHAddr()) - - packet.SetXId(messageid) - packet.SetCIAddr(acknowledgement.YIAddr()) - packet.SetSIAddr(acknowledgement.SIAddr()) - - packet.SetBroadcast(c.broadcast) - packet.AddOption(dhcp4.OptionDHCPMessageType, []byte{byte(dhcp4.Request)}) - packet.AddOption(dhcp4.OptionRequestedIPAddress, (acknowledgement.YIAddr()).To4()) - packet.AddOption(dhcp4.OptionServerIdentifier, acknowledgementOptions[dhcp4.OptionServerIdentifier]) - - return packet -} - -//Create Release Packet For a Release -func (c *Client) ReleasePacket(acknowledgement *dhcp4.Packet) dhcp4.Packet { - messageid := make([]byte, 4) - c.generateXID(messageid) - - acknowledgementOptions := acknowledgement.ParseOptions() - - packet := dhcp4.NewPacket(dhcp4.BootRequest) - packet.SetCHAddr(acknowledgement.CHAddr()) - - packet.SetXId(messageid) - packet.SetCIAddr(acknowledgement.YIAddr()) - - packet.AddOption(dhcp4.OptionDHCPMessageType, []byte{byte(dhcp4.Release)}) - packet.AddOption(dhcp4.OptionServerIdentifier, acknowledgementOptions[dhcp4.OptionServerIdentifier]) - - return packet -} - -//Create Decline Packet -func (c *Client) DeclinePacket(acknowledgement *dhcp4.Packet) dhcp4.Packet { - messageid := make([]byte, 4) - c.generateXID(messageid) - - acknowledgementOptions := acknowledgement.ParseOptions() - - packet := dhcp4.NewPacket(dhcp4.BootRequest) - packet.SetCHAddr(acknowledgement.CHAddr()) - packet.SetXId(messageid) - - packet.AddOption(dhcp4.OptionDHCPMessageType, []byte{byte(dhcp4.Decline)}) - packet.AddOption(dhcp4.OptionRequestedIPAddress, (acknowledgement.YIAddr()).To4()) - packet.AddOption(dhcp4.OptionServerIdentifier, acknowledgementOptions[dhcp4.OptionServerIdentifier]) - - return packet -} - - -//Lets do a Full DHCP Request. -func (c *Client) Request() (bool, dhcp4.Packet, error) { - discoveryPacket, err := c.SendDiscoverPacket() - if err != nil { - return false, discoveryPacket, err - } - - offerPacket, err := c.GetOffer(&discoveryPacket) - if err != nil { - return false, offerPacket, err - } - - requestPacket, err := c.SendRequest(&offerPacket) - if err != nil { - return false, requestPacket, err - } - - acknowledgement, err := c.GetAcknowledgement(&requestPacket) - if err != nil { - return false, acknowledgement, err - } - - acknowledgementOptions := acknowledgement.ParseOptions() - if dhcp4.MessageType(acknowledgementOptions[dhcp4.OptionDHCPMessageType][0]) != dhcp4.ACK { - return false, acknowledgement, nil - } - - return true, acknowledgement, nil -} - -//Renew a lease backed on the Acknowledgement Packet. -//Returns Sucessfull, The AcknoledgementPacket, Any Errors -func (c *Client) Renew(acknowledgement dhcp4.Packet) (bool, dhcp4.Packet, error) { - renewRequest := c.RenewalRequestPacket(&acknowledgement) - renewRequest.PadToMinSize() - - err := c.SendPacket(renewRequest) - if err != nil { - return false, renewRequest, err - } - - newAcknowledgement, err := c.GetAcknowledgement(&renewRequest) - if err != nil { - return false, newAcknowledgement, err - } - - newAcknowledgementOptions := newAcknowledgement.ParseOptions() - if dhcp4.MessageType(newAcknowledgementOptions[dhcp4.OptionDHCPMessageType][0]) != dhcp4.ACK { - return false, newAcknowledgement, nil - } - - return true, newAcknowledgement, nil -} - -//Release a lease backed on the Acknowledgement Packet. -//Returns Any Errors -func (c *Client) Release(acknowledgement dhcp4.Packet) error { - release := c.ReleasePacket(&acknowledgement) - release.PadToMinSize() - - return c.SendPacket(release) -} diff --git a/vendor/github.com/d2g/dhcp4client/generatexid.go b/vendor/github.com/d2g/dhcp4client/generatexid.go deleted file mode 100644 index 6e9ffbcde7a..00000000000 --- a/vendor/github.com/d2g/dhcp4client/generatexid.go +++ /dev/null @@ -1,18 +0,0 @@ -package dhcp4client - -import ( - cryptorand "crypto/rand" - mathrand "math/rand" -) - -func CryptoGenerateXID(b []byte) { - if _, err := cryptorand.Read(b); err != nil { - panic(err) - } -} - -func MathGenerateXID(b []byte) { - if _, err := mathrand.Read(b); err != nil { - panic(err) - } -} diff --git a/vendor/github.com/d2g/dhcp4client/inetsock.go b/vendor/github.com/d2g/dhcp4client/inetsock.go deleted file mode 100644 index 293f186538c..00000000000 --- a/vendor/github.com/d2g/dhcp4client/inetsock.go +++ /dev/null @@ -1,75 +0,0 @@ -package dhcp4client - -import ( - "net" - "time" -) - -type inetSock struct { - *net.UDPConn - - laddr net.UDPAddr - raddr net.UDPAddr -} - -func NewInetSock(options ...func(*inetSock) error) (*inetSock, error) { - c := &inetSock{ - laddr: net.UDPAddr{IP: net.IPv4(0, 0, 0, 0), Port: 68}, - raddr: net.UDPAddr{IP: net.IPv4bcast, Port: 67}, - } - - err := c.setOption(options...) - if err != nil { - return nil, err - } - - conn, err := net.ListenUDP("udp4", &c.laddr) - if err != nil { - return nil, err - } - - c.UDPConn = conn - return c, err -} - -func (c *inetSock) setOption(options ...func(*inetSock) error) error { - for _, opt := range options { - if err := opt(c); err != nil { - return err - } - } - return nil -} - -func SetLocalAddr(l net.UDPAddr) func(*inetSock) error { - return func(c *inetSock) error { - c.laddr = l - return nil - } -} - -func SetRemoteAddr(r net.UDPAddr) func(*inetSock) error { - return func(c *inetSock) error { - c.raddr = r - return nil - } -} - -func (c *inetSock) Write(packet []byte) error { - _, err := c.WriteToUDP(packet, &c.raddr) - return err -} - -func (c *inetSock) ReadFrom() ([]byte, net.IP, error) { - readBuffer := make([]byte, MaxDHCPLen) - n, source, err := c.ReadFromUDP(readBuffer) - if source != nil { - return readBuffer[:n], source.IP, err - } else { - return readBuffer[:n], net.IP{}, err - } -} - -func (c *inetSock) SetReadTimeout(t time.Duration) error { - return c.SetReadDeadline(time.Now().Add(t)) -} diff --git a/vendor/github.com/d2g/dhcp4client/pktsock_linux.go b/vendor/github.com/d2g/dhcp4client/pktsock_linux.go deleted file mode 100644 index a21c265fb4a..00000000000 --- a/vendor/github.com/d2g/dhcp4client/pktsock_linux.go +++ /dev/null @@ -1,147 +0,0 @@ -package dhcp4client - -import ( - "crypto/rand" - "encoding/binary" - "net" - "time" - - "golang.org/x/sys/unix" -) - -const ( - minIPHdrLen = 20 - maxIPHdrLen = 60 - udpHdrLen = 8 - ip4Ver = 0x40 - ttl = 16 - srcPort = 68 - dstPort = 67 -) - -var ( - bcastMAC = []byte{255, 255, 255, 255, 255, 255} -) - -// abstracts AF_PACKET -type packetSock struct { - fd int - ifindex int -} - -func NewPacketSock(ifindex int) (*packetSock, error) { - fd, err := unix.Socket(unix.AF_PACKET, unix.SOCK_DGRAM, int(swap16(unix.ETH_P_IP))) - if err != nil { - return nil, err - } - - addr := unix.SockaddrLinklayer{ - Ifindex: ifindex, - Protocol: swap16(unix.ETH_P_IP), - } - - if err = unix.Bind(fd, &addr); err != nil { - return nil, err - } - - return &packetSock{ - fd: fd, - ifindex: ifindex, - }, nil -} - -func (pc *packetSock) Close() error { - return unix.Close(pc.fd) -} - -func (pc *packetSock) Write(packet []byte) error { - lladdr := unix.SockaddrLinklayer{ - Ifindex: pc.ifindex, - Protocol: swap16(unix.ETH_P_IP), - Halen: uint8(len(bcastMAC)), - } - copy(lladdr.Addr[:], bcastMAC) - - pkt := make([]byte, minIPHdrLen+udpHdrLen+len(packet)) - - fillIPHdr(pkt[0:minIPHdrLen], udpHdrLen+uint16(len(packet))) - fillUDPHdr(pkt[minIPHdrLen:minIPHdrLen+udpHdrLen], uint16(len(packet))) - - // payload - copy(pkt[minIPHdrLen+udpHdrLen:len(pkt)], packet) - - return unix.Sendto(pc.fd, pkt, 0, &lladdr) -} - -func (pc *packetSock) ReadFrom() ([]byte, net.IP, error) { - pkt := make([]byte, maxIPHdrLen+udpHdrLen+MaxDHCPLen) - n, _, err := unix.Recvfrom(pc.fd, pkt, 0) - if err != nil { - return nil, nil, err - } - - // IP hdr len - ihl := int(pkt[0]&0x0F) * 4 - // Source IP address - src := net.IP(pkt[12:16]) - - return pkt[ihl+udpHdrLen : n], src, nil -} - -func (pc *packetSock) SetReadTimeout(t time.Duration) error { - - tv := unix.NsecToTimeval(t.Nanoseconds()) - return unix.SetsockoptTimeval(pc.fd, unix.SOL_SOCKET, unix.SO_RCVTIMEO, &tv) -} - -// compute's 1's complement checksum -func chksum(p []byte, csum []byte) { - cklen := len(p) - s := uint32(0) - for i := 0; i < (cklen - 1); i += 2 { - s += uint32(p[i+1])<<8 | uint32(p[i]) - } - if cklen&1 == 1 { - s += uint32(p[cklen-1]) - } - s = (s >> 16) + (s & 0xffff) - s = s + (s >> 16) - s = ^s - - csum[0] = uint8(s & 0xff) - csum[1] = uint8(s >> 8) -} - -func fillIPHdr(hdr []byte, payloadLen uint16) { - // version + IHL - hdr[0] = ip4Ver | (minIPHdrLen / 4) - // total length - binary.BigEndian.PutUint16(hdr[2:4], uint16(len(hdr))+payloadLen) - // identification - if _, err := rand.Read(hdr[4:5]); err != nil { - panic(err) - } - // TTL - hdr[8] = 16 - // Protocol - hdr[9] = unix.IPPROTO_UDP - // dst IP - copy(hdr[16:20], net.IPv4bcast.To4()) - // compute IP hdr checksum - chksum(hdr[0:len(hdr)], hdr[10:12]) -} - -func fillUDPHdr(hdr []byte, payloadLen uint16) { - // src port - binary.BigEndian.PutUint16(hdr[0:2], srcPort) - // dest port - binary.BigEndian.PutUint16(hdr[2:4], dstPort) - // length - binary.BigEndian.PutUint16(hdr[4:6], udpHdrLen+payloadLen) -} - -func swap16(x uint16) uint16 { - var b [2]byte - binary.BigEndian.PutUint16(b[:], x) - return binary.LittleEndian.Uint16(b[:]) -} diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/LICENSE b/vendor/github.com/vmware/photon-controller-go-sdk/LICENSE deleted file mode 100644 index a7152370b5c..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/LICENSE +++ /dev/null @@ -1,74 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - -"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. - -"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. - -"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. - -"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. - -"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. - -"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. - -"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). - -"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. - -"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." - -"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: -(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and -(b) You must cause any modified files to carry prominent notices stating that You changed the files; and -(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and -(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. - -You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - -To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied. - - See the License for the specific language governing permissions and - limitations under the License. - - diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/SSPI/BUILD b/vendor/github.com/vmware/photon-controller-go-sdk/SSPI/BUILD deleted file mode 100644 index 81f05cd74ec..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/SSPI/BUILD +++ /dev/null @@ -1,26 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -go_library( - name = "go_default_library", - srcs = [ - "sspi.go", - "sspi_unsupported.go", - ], - importmap = "k8s.io/kubernetes/vendor/github.com/vmware/photon-controller-go-sdk/SSPI", - importpath = "github.com/vmware/photon-controller-go-sdk/SSPI", - visibility = ["//visibility:public"], -) - -filegroup( - name = "package-srcs", - srcs = glob(["**"]), - tags = ["automanaged"], - visibility = ["//visibility:private"], -) - -filegroup( - name = "all-srcs", - srcs = [":package-srcs"], - tags = ["automanaged"], - visibility = ["//visibility:public"], -) diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/SSPI/LICENSE.txt b/vendor/github.com/vmware/photon-controller-go-sdk/SSPI/LICENSE.txt deleted file mode 100644 index 0f2498b1939..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/SSPI/LICENSE.txt +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2012 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/SSPI/README.md b/vendor/github.com/vmware/photon-controller-go-sdk/SSPI/README.md deleted file mode 100644 index 5ca992428d4..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/SSPI/README.md +++ /dev/null @@ -1,3 +0,0 @@ -SSPI implementation in this directory is taken from https://github.com/WillHipschman/sspi-prototype (git commit: 4feee8f2e75857bb51345fdfc8e3c091edc959b4) -Implementation is modified to make sure that it only compiles on Windows. -For non-Windows platforms, please look at sspi_unspported.go diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/SSPI/sspi.go b/vendor/github.com/vmware/photon-controller-go-sdk/SSPI/sspi.go deleted file mode 100644 index 5baa83cc4cf..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/SSPI/sspi.go +++ /dev/null @@ -1,276 +0,0 @@ -// +build windows - -package SSPI - -import ( - "fmt" - "strings" - "syscall" - "unsafe" -) - -var ( - secur32_dll = syscall.NewLazyDLL("secur32.dll") - initSecurityInterface = secur32_dll.NewProc("InitSecurityInterfaceW") - sec_fn *SecurityFunctionTable -) - -func init() { - ptr, _, _ := initSecurityInterface.Call() - sec_fn = (*SecurityFunctionTable)(unsafe.Pointer(ptr)) -} - -const ( - SEC_E_OK = 0 - SECPKG_CRED_OUTBOUND = 2 - SEC_WINNT_AUTH_IDENTITY_UNICODE = 2 - ISC_REQ_DELEGATE = 0x00000001 - ISC_REQ_REPLAY_DETECT = 0x00000004 - ISC_REQ_SEQUENCE_DETECT = 0x00000008 - ISC_REQ_CONFIDENTIALITY = 0x00000010 - ISC_REQ_CONNECTION = 0x00000800 - SECURITY_NETWORK_DREP = 0 - SEC_I_CONTINUE_NEEDED = 0x00090312 - SEC_I_COMPLETE_NEEDED = 0x00090313 - SEC_I_COMPLETE_AND_CONTINUE = 0x00090314 - SECBUFFER_VERSION = 0 - SECBUFFER_TOKEN = 2 - NTLMBUF_LEN = 12000 -) - -const ISC_REQ = ISC_REQ_CONFIDENTIALITY | - ISC_REQ_REPLAY_DETECT | - ISC_REQ_SEQUENCE_DETECT | - ISC_REQ_CONNECTION | - ISC_REQ_DELEGATE - -type SecurityFunctionTable struct { - dwVersion uint32 - EnumerateSecurityPackages uintptr - QueryCredentialsAttributes uintptr - AcquireCredentialsHandle uintptr - FreeCredentialsHandle uintptr - Reserved2 uintptr - InitializeSecurityContext uintptr - AcceptSecurityContext uintptr - CompleteAuthToken uintptr - DeleteSecurityContext uintptr - ApplyControlToken uintptr - QueryContextAttributes uintptr - ImpersonateSecurityContext uintptr - RevertSecurityContext uintptr - MakeSignature uintptr - VerifySignature uintptr - FreeContextBuffer uintptr - QuerySecurityPackageInfo uintptr - Reserved3 uintptr - Reserved4 uintptr - Reserved5 uintptr - Reserved6 uintptr - Reserved7 uintptr - Reserved8 uintptr - QuerySecurityContextToken uintptr - EncryptMessage uintptr - DecryptMessage uintptr -} - -type SEC_WINNT_AUTH_IDENTITY struct { - User *uint16 - UserLength uint32 - Domain *uint16 - DomainLength uint32 - Password *uint16 - PasswordLength uint32 - Flags uint32 -} - -type TimeStamp struct { - LowPart uint32 - HighPart int32 -} - -type SecHandle struct { - dwLower uintptr - dwUpper uintptr -} - -type SecBuffer struct { - cbBuffer uint32 - BufferType uint32 - pvBuffer *byte -} - -type SecBufferDesc struct { - ulVersion uint32 - cBuffers uint32 - pBuffers *SecBuffer -} - -type SSPIAuth struct { - Domain string - UserName string - Password string - Service string - cred SecHandle - ctxt SecHandle -} - -type Auth interface { - InitialBytes() ([]byte, error) - NextBytes([]byte) ([]byte, error) - Free() -} - -// GetAuth returns SSPI auth object initialized with given params and true for success -// In case of error, it will return nil SSPI object and false for failure -func GetAuth(user, password, service, workstation string) (Auth, bool) { - if user == "" { - return &SSPIAuth{Service: service}, true - } - if !strings.ContainsRune(user, '\\') { - return nil, false - } - domain_user := strings.SplitN(user, "\\", 2) - return &SSPIAuth{ - Domain: domain_user[0], - UserName: domain_user[1], - Password: password, - Service: service, - }, true -} - -func (auth *SSPIAuth) InitialBytes() ([]byte, error) { - var identity *SEC_WINNT_AUTH_IDENTITY - if auth.UserName != "" { - identity = &SEC_WINNT_AUTH_IDENTITY{ - Flags: SEC_WINNT_AUTH_IDENTITY_UNICODE, - Password: syscall.StringToUTF16Ptr(auth.Password), - PasswordLength: uint32(len(auth.Password)), - Domain: syscall.StringToUTF16Ptr(auth.Domain), - DomainLength: uint32(len(auth.Domain)), - User: syscall.StringToUTF16Ptr(auth.UserName), - UserLength: uint32(len(auth.UserName)), - } - } - var ts TimeStamp - sec_ok, _, _ := syscall.Syscall9(sec_fn.AcquireCredentialsHandle, - 9, - 0, - uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr("Negotiate"))), - SECPKG_CRED_OUTBOUND, - 0, - uintptr(unsafe.Pointer(identity)), - 0, - 0, - uintptr(unsafe.Pointer(&auth.cred)), - uintptr(unsafe.Pointer(&ts))) - if sec_ok != SEC_E_OK { - return nil, fmt.Errorf("AcquireCredentialsHandle failed %x", sec_ok) - } - - var buf SecBuffer - var desc SecBufferDesc - desc.ulVersion = SECBUFFER_VERSION - desc.cBuffers = 1 - desc.pBuffers = &buf - - outbuf := make([]byte, NTLMBUF_LEN) - buf.cbBuffer = NTLMBUF_LEN - buf.BufferType = SECBUFFER_TOKEN - buf.pvBuffer = &outbuf[0] - - var attrs uint32 - sec_ok, _, _ = syscall.Syscall12(sec_fn.InitializeSecurityContext, - 12, - uintptr(unsafe.Pointer(&auth.cred)), - 0, - uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(auth.Service))), - ISC_REQ, - 0, - SECURITY_NETWORK_DREP, - 0, - 0, - uintptr(unsafe.Pointer(&auth.ctxt)), - uintptr(unsafe.Pointer(&desc)), - uintptr(unsafe.Pointer(&attrs)), - uintptr(unsafe.Pointer(&ts))) - if sec_ok == SEC_I_COMPLETE_AND_CONTINUE || - sec_ok == SEC_I_COMPLETE_NEEDED { - syscall.Syscall6(sec_fn.CompleteAuthToken, - 2, - uintptr(unsafe.Pointer(&auth.ctxt)), - uintptr(unsafe.Pointer(&desc)), - 0, 0, 0, 0) - } else if sec_ok != SEC_E_OK && - sec_ok != SEC_I_CONTINUE_NEEDED { - syscall.Syscall6(sec_fn.FreeCredentialsHandle, - 1, - uintptr(unsafe.Pointer(&auth.cred)), - 0, 0, 0, 0, 0) - return nil, fmt.Errorf("InitialBytes InitializeSecurityContext failed %x", sec_ok) - } - return outbuf[:buf.cbBuffer], nil -} - -func (auth *SSPIAuth) NextBytes(bytes []byte) ([]byte, error) { - var in_buf, out_buf SecBuffer - var in_desc, out_desc SecBufferDesc - - in_desc.ulVersion = SECBUFFER_VERSION - in_desc.cBuffers = 1 - in_desc.pBuffers = &in_buf - - out_desc.ulVersion = SECBUFFER_VERSION - out_desc.cBuffers = 1 - out_desc.pBuffers = &out_buf - - in_buf.BufferType = SECBUFFER_TOKEN - in_buf.pvBuffer = &bytes[0] - in_buf.cbBuffer = uint32(len(bytes)) - - outbuf := make([]byte, NTLMBUF_LEN) - out_buf.BufferType = SECBUFFER_TOKEN - out_buf.pvBuffer = &outbuf[0] - out_buf.cbBuffer = NTLMBUF_LEN - - var attrs uint32 - var ts TimeStamp - sec_ok, _, _ := syscall.Syscall12(sec_fn.InitializeSecurityContext, - 12, - uintptr(unsafe.Pointer(&auth.cred)), - uintptr(unsafe.Pointer(&auth.ctxt)), - uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(auth.Service))), - ISC_REQ, - 0, - SECURITY_NETWORK_DREP, - uintptr(unsafe.Pointer(&in_desc)), - 0, - uintptr(unsafe.Pointer(&auth.ctxt)), - uintptr(unsafe.Pointer(&out_desc)), - uintptr(unsafe.Pointer(&attrs)), - uintptr(unsafe.Pointer(&ts))) - if sec_ok == SEC_I_COMPLETE_AND_CONTINUE || - sec_ok == SEC_I_COMPLETE_NEEDED { - syscall.Syscall6(sec_fn.CompleteAuthToken, - 2, - uintptr(unsafe.Pointer(&auth.ctxt)), - uintptr(unsafe.Pointer(&out_desc)), - 0, 0, 0, 0) - } else if sec_ok != SEC_E_OK && - sec_ok != SEC_I_CONTINUE_NEEDED { - return nil, fmt.Errorf("NextBytes InitializeSecurityContext failed %x", sec_ok) - } - - return outbuf[:out_buf.cbBuffer], nil -} - -func (auth *SSPIAuth) Free() { - syscall.Syscall6(sec_fn.DeleteSecurityContext, - 1, - uintptr(unsafe.Pointer(&auth.ctxt)), - 0, 0, 0, 0, 0) - syscall.Syscall6(sec_fn.FreeCredentialsHandle, - 1, - uintptr(unsafe.Pointer(&auth.cred)), - 0, 0, 0, 0, 0) -} \ No newline at end of file diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/SSPI/sspi_unsupported.go b/vendor/github.com/vmware/photon-controller-go-sdk/SSPI/sspi_unsupported.go deleted file mode 100644 index a8cb141299d..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/SSPI/sspi_unsupported.go +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) 2017 VMware, Inc. All Rights Reserved. -// -// This product is licensed to you under the Apache License, Version 2.0 (the "License"). -// You may not use this product except in compliance with the License. -// -// This product may include a number of subcomponents with separate copyright notices and -// license terms. Your use of these subcomponents is subject to the terms and conditions -// of the subcomponent's license, as noted in the LICENSE file. - -// +build !windows - -package SSPI diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/BUILD b/vendor/github.com/vmware/photon-controller-go-sdk/photon/BUILD deleted file mode 100644 index 528e4615b97..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/BUILD +++ /dev/null @@ -1,51 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -go_library( - name = "go_default_library", - srcs = [ - "apitypes.go", - "auth.go", - "availabilityzones.go", - "client.go", - "deployments.go", - "disks.go", - "flavors.go", - "hosts.go", - "images.go", - "info.go", - "networks.go", - "projects.go", - "resourcetickets.go", - "restclient.go", - "routers.go", - "services.go", - "status.go", - "subnets.go", - "tasks.go", - "tenants.go", - "util.go", - "virtualnetworks.go", - "vms.go", - ], - importmap = "k8s.io/kubernetes/vendor/github.com/vmware/photon-controller-go-sdk/photon", - importpath = "github.com/vmware/photon-controller-go-sdk/photon", - visibility = ["//visibility:public"], - deps = ["//vendor/github.com/vmware/photon-controller-go-sdk/photon/lightwave:go_default_library"], -) - -filegroup( - name = "package-srcs", - srcs = glob(["**"]), - tags = ["automanaged"], - visibility = ["//visibility:private"], -) - -filegroup( - name = "all-srcs", - srcs = [ - ":package-srcs", - "//vendor/github.com/vmware/photon-controller-go-sdk/photon/lightwave:all-srcs", - ], - tags = ["automanaged"], - visibility = ["//visibility:public"], -) diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/apitypes.go b/vendor/github.com/vmware/photon-controller-go-sdk/photon/apitypes.go deleted file mode 100644 index dae59a385b3..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/apitypes.go +++ /dev/null @@ -1,802 +0,0 @@ -// Copyright (c) 2016 VMware, Inc. All Rights Reserved. -// -// This product is licensed to you under the Apache License, Version 2.0 (the "License"). -// You may not use this product except in compliance with the License. -// -// This product may include a number of subcomponents with separate copyright notices and -// license terms. Your use of these subcomponents is subject to the terms and conditions -// of the subcomponent's license, as noted in the LICENSE file. - -package photon - -import ( - "fmt" -) - -type Entity struct { - ID string `json:"id"` - Kind string `json:"kind"` -} - -// Implement a generic sdk error -type SdkError struct { - Message string -} - -func (e SdkError) Error() string { - return fmt.Sprintf("photon: %v", e.Message) -} - -// Represents an error from the Photon API. -type ApiError struct { - Code string `json:"code"` - Data map[string]interface{} `json:"data"` - Message string `json:"message"` - HttpStatusCode int `json:"-"` // Not part of API contract -} - -// Implement Go error interface for ApiError -func (e ApiError) Error() string { - return fmt.Sprintf( - "photon: { HTTP status: '%v', code: '%v', message: '%v', data: '%v' }", - e.HttpStatusCode, - e.Code, - e.Message, - e.Data) -} - -// Used to represent a generic HTTP error, i.e. an unexpected HTTP 500. -type HttpError struct { - StatusCode int - Message string -} - -// Implementation of error interface for HttpError -func (e HttpError) Error() string { - return fmt.Sprintf("photon: HTTP %d: %v", e.StatusCode, e.Message) -} - -// Represents an Photon task that has entered into an error state. -// Photon task errors can be caught and type-checked against with -// the usual Go idiom. -type TaskError struct { - ID string `json:"id"` - Step Step `json:"step,omitempty"` -} - -// Implement Go error interface for TaskError. -func (e TaskError) Error() string { - return fmt.Sprintf("photon: Task '%s' is in error state: {@step==%s}", e.ID, GetStep(e.Step)) -} - -// An error representing a timeout while waiting for a task to complete. -type TaskTimeoutError struct { - ID string -} - -// Implement Go error interface for TaskTimeoutError. -func (e TaskTimeoutError) Error() string { - return fmt.Sprintf("photon: Timed out waiting for task '%s'. "+ - "Task may not be in error state, examine task for full details.", e.ID) -} - -// Represents an operation (Step) within a Task. -type Step struct { - ID string `json:"id"` - Operation string `json:"operation,omitempty"` - State string `json:"state"` - StartedTime int64 `json:"startedTime"` - EndTime int64 `json:"endTime,omitempty"` - QueuedTime int64 `json:"queuedTime"` - Sequence int `json:"sequence,omitempty"` - ResourceProperties map[string]interface{} `json:"resourceProperties,omitempty"` - Errors []ApiError `json:"errors,omitempty"` - Warnings []ApiError `json:"warnings,omitempty"` - Options map[string]interface{} `json:"options,omitempty"` - SelfLink string `json:"selfLink,omitempty"` -} - -// Implement Go error interface for Step. -func GetStep(s Step) string { - return fmt.Sprintf("{\"sequence\"=>\"%d\",\"state\"=>\"%s\",\"errors\"=>%s,\"warnings\"=>%s,\"operation\"=>\"%s\","+ - "\"startedTime\"=>\"%d\",\"queuedTime\"=>\"%d\",\"endTime\"=>\"%d\",\"options\"=>%s}", - s.Sequence, s.State, s.Errors, s.Warnings, s.Operation, s.StartedTime, s.QueuedTime, - s.EndTime, s.Options) - -} - -// Represents an asynchronous task. -type Task struct { - ID string `json:"id"` - Operation string `json:"operation,omitempty"` - State string `json:"state"` - StartedTime int64 `json:"startedTime"` - EndTime int64 `json:"endTime,omitempty"` - QueuedTime int64 `json:"queuedTime"` - Entity Entity `json:"entity,omitempty"` - SelfLink string `json:"selfLink,omitempty"` - Steps []Step `json:"steps,omitempty"` - ResourceProperties interface{} `json:"resourceProperties,omitempty"` -} - -// Represents multiple tasks returned by the API. -type TaskList struct { - Items []Task `json:"items"` -} - -// Options for GetTasks API. -type TaskGetOptions struct { - State string `urlParam:"state"` - Kind string `urlParam:"kind"` - EntityID string `urlParam:"entityId"` - EntityKind string `urlParam:"entityKind"` -} - -type BaseCompact struct { - Name string `json:"name"` - ID string `json:"id"` -} - -type QuotaLineItem struct { - Unit string `json:"unit"` - Value float64 `json:"value"` - Key string `json:"key"` -} - -// Creation spec for locality. -type LocalitySpec struct { - Kind string `json:"kind"` - ID string `json:"id"` -} - -// Creation spec for disks. -type DiskCreateSpec struct { - Flavor string `json:"flavor"` - Kind string `json:"kind"` - CapacityGB int `json:"capacityGb"` - Affinities []LocalitySpec `json:"affinities,omitempty"` - Name string `json:"name"` - Tags []string `json:"tags,omitempty"` -} - -// Represents a persistent disk. -type PersistentDisk struct { - Flavor string `json:"flavor"` - Cost []QuotaLineItem `json:"cost"` - Kind string `json:"kind"` - Datastore string `json:"datastore,omitempty"` - CapacityGB int `json:"capacityGb,omitempty"` - Name string `json:"name"` - State string `json:"state"` - ID string `json:"id"` - VMs []string `json:"vms"` - Tags []string `json:"tags,omitempty"` - SelfLink string `json:"selfLink,omitempty"` -} - -// Represents multiple persistent disks returned by the API. -type DiskList struct { - Items []PersistentDisk `json:"items"` -} - -// Creation spec for projects. -type ProjectCreateSpec struct { - ResourceTicket ResourceTicketReservation `json:"resourceTicket"` - Name string `json:"name"` - SecurityGroups []string `json:"securityGroups,omitempty"` -} - -// Represents multiple projects returned by the API. -type ProjectList struct { - Items []ProjectCompact `json:"items"` -} - -// Compact representation of projects. -type ProjectCompact struct { - Kind string `json:"kind"` - ResourceTicket ProjectTicket `json:"resourceTicket"` - Name string `json:"name"` - ID string `json:"id"` - Tags []string `json:"tags"` - SelfLink string `json:"selfLink"` - SecurityGroups []SecurityGroup `json:"securityGroups"` -} - -type ProjectTicket struct { - TenantTicketID string `json:"tenantTicketId"` - Usage []QuotaLineItem `json:"usage"` - TenantTicketName string `json:"tenantTicketName"` - Limits []QuotaLineItem `json:"limits"` -} - -// Represents an image. -type Image struct { - Size int64 `json:"size"` - Kind string `json:"kind"` - Name string `json:"name"` - State string `json:"state"` - ID string `json:"id"` - Tags []string `json:"tags"` - SelfLink string `json:"selfLink"` - Settings []ImageSetting `json:"settings"` - ReplicationType string `json:"replicationType"` - ReplicationProgress string `json:"replicationProgress"` - SeedingProgress string `json:"seedingProgress"` -} - -// Represents an image setting -type ImageSetting struct { - Name string `json:"name"` - DefaultValue string `json:"defaultValue"` -} - -// Creation spec for images. -type ImageCreateOptions struct { - ReplicationType string -} - -// Represents multiple images returned by the API. -type Images struct { - Items []Image `json:"items"` -} - -// Represents a component with status. -type Component struct { - Component string - Message string - Status string -} - -// Represents status of the photon system. -type Status struct { - Status string - Components []Component -} - -// Represents a single tenant. -type Tenant struct { - Projects []BaseCompact `json:"projects"` - ResourceTickets []BaseCompact `json:"resourceTickets"` - Kind string `json:"kind"` - Name string `json:"name"` - ID string `json:"id"` - SelfLink string `json:"selfLink"` - Tags []string `json:"tags"` - SecurityGroups []SecurityGroup `json:"securityGroups"` -} - -// Represents multiple tenants returned by the API. -type Tenants struct { - Items []Tenant `json:"items"` -} - -// Creation spec for tenants. -type TenantCreateSpec struct { - Name string `json:"name"` - SecurityGroups []string `json:"securityGroups,omitempty"` -} - -// Creation spec for resource tickets. -type ResourceTicketCreateSpec struct { - Name string `json:"name"` - Limits []QuotaLineItem `json:"limits"` -} - -// Represents a single resource ticket. -type ResourceTicket struct { - Kind string `json:"kind"` - Usage []QuotaLineItem `json:"usage"` - TenantId string `json:"tenantId"` - Name string `json:"name"` - ID string `json:"id"` - Limits []QuotaLineItem `json:"limits"` - Tags []string `json:"tags"` - SelfLink string `json:"selfLink"` -} - -// Represents multiple resource tickets returned by the API. -type ResourceList struct { - Items []ResourceTicket `json:"items"` -} - -// Represents a resource reservation on a resource ticket. -type ResourceTicketReservation struct { - Name string `json:"name"` - Limits []QuotaLineItem `json:"limits"` -} - -// Creation spec for VMs. -type VmCreateSpec struct { - Flavor string `json:"flavor"` - SourceImageID string `json:"sourceImageId"` - AttachedDisks []AttachedDisk `json:"attachedDisks"` - Affinities []LocalitySpec `json:"affinities,omitempty"` - Name string `json:"name"` - Tags []string `json:"tags,omitempty"` - Subnets []string `json:"subnets,omitempty"` - Environment map[string]string `json:"environment,omitempty"` -} - -// Represents possible operations for VMs. Valid values include: -// START_VM, STOP_VM, RESTART_VM, SUSPEND_VM, RESUME_VM -type VmOperation struct { - Operation string `json:"operation"` - Arguments map[string]interface{} `json:"arguments,omitempty"` -} - -// Represents metadata that can be set on a VM. -type VmMetadata struct { - Metadata map[string]string `json:"metadata"` -} - -// Represents tags that can be set on a VM. -type VmTag struct { - Tag string `json:"value"` -} - -// Represents a single attached disk. -type AttachedDisk struct { - Flavor string `json:"flavor"` - Kind string `json:"kind"` - CapacityGB int `json:"capacityGb,omitempty"` - Name string `json:"name"` - State string `json:"state"` - ID string `json:"id,omitempty"` - BootDisk bool `json:"bootDisk"` -} - -// Represents a single VM. -type VM struct { - SourceImageID string `json:"sourceImageId,omitempty"` - Cost []QuotaLineItem `json:"cost"` - Kind string `json:"kind"` - AttachedDisks []AttachedDisk `json:"attachedDisks"` - Datastore string `json:"datastore,omitempty"` - AttachedISOs []ISO `json:"attachedIsos,omitempty"` - Tags []string `json:"tags,omitempty"` - Metadata map[string]string `json:"metadata,omitempty"` - SelfLink string `json:"selfLink,omitempty"` - Flavor string `json:"flavor"` - Host string `json:"host,omitempty"` - Name string `json:"name"` - State string `json:"state"` - ID string `json:"id"` - FloatingIp string `json:"floatingIp"` -} - -// Represents multiple VMs returned by the API. -type VMs struct { - Items []VM `json:"items"` -} - -// Represents an ISO. -type ISO struct { - Size int64 `json:"size,omitempty"` - Kind string `json:"kind,omitempty"` - Name string `json:"name"` - ID string `json:"id"` -} - -// Represents operations for disks. -type VmDiskOperation struct { - DiskID string `json:"diskId"` - Arguments map[string]interface{} `json:"arguments,omitempty"` -} - -// Represents a floating IP operation related to a VM. -type VmFloatingIpSpec struct { - NetworkId string `json:"networkId"` -} - -// Creation spec for flavors. -type FlavorCreateSpec struct { - Cost []QuotaLineItem `json:"cost"` - Kind string `json:"kind"` - Name string `json:"name"` -} - -// Represents a single flavor. -type Flavor struct { - Cost []QuotaLineItem `json:"cost"` - Kind string `json:"kind"` - Name string `json:"name"` - ID string `json:"id"` - Tags []string `json:"tags"` - SelfLink string `json:"selfLink"` - State string `json:"state"` -} - -// Represents multiple flavors returned by the API. -type FlavorList struct { - Items []Flavor `json:"items"` -} - -// Creation spec for hosts. -type HostCreateSpec struct { - Username string `json:"username"` - Password string `json:"password"` - AvailabilityZone string `json:"availabilityZone,omitempty"` - Metadata map[string]string `json:"metadata,omitempty"` - Address string `json:"address"` - Tags []string `json:"usageTags"` -} - -// Represents a host -type Host struct { - Username string `json:"username"` - Password string `json:"password"` - Address string `json:"address"` - Kind string `json:"kind"` - ID string `json:"id"` - AvailabilityZone string `json:"availabilityZone,omitempty"` - Tags []string `json:"usageTags"` - Metadata map[string]string `json:"metadata,omitempty"` - SelfLink string `json:"selfLink"` - State string `json:"state"` - EsxVersion string `json:"esxVersion"` -} - -// Represents multiple hosts returned by the API. -type Hosts struct { - Items []Host `json:"items"` -} - -// Creation spec for deployments. -type DeploymentCreateSpec struct { - NTPEndpoint interface{} `json:"ntpEndpoint"` - UseImageDatastoreForVms bool `json:"useImageDatastoreForVms"` - SyslogEndpoint interface{} `json:"syslogEndpoint"` - Stats *StatsInfo `json:"stats"` - ImageDatastores []string `json:"imageDatastores"` - Auth *AuthInfo `json:"auth"` - NetworkConfiguration *NetworkConfigurationCreateSpec `json:"networkConfiguration"` - LoadBalancerEnabled bool `json:"loadBalancerEnabled"` -} - -// Deployment deploy config. -type DeploymentDeployOperation struct { - DesiredState string `json:"desiredState"` -} - -type MigrationStatus struct { - CompletedDataMigrationCycles int `json:"completedDataMigrationCycles"` - DataMigrationCycleProgress int `json:"dataMigrationCycleProgress"` - DataMigrationCycleSize int `json:"dataMigrationCycleSize"` - VibsUploaded int `json:"vibsUploaded"` - VibsUploading int `json:"vibsUploading"` -} - -// Represents a deployment -type Deployment struct { - NTPEndpoint string `json:"ntpEndpoint,omitempty"` - UseImageDatastoreForVms bool `json:"useImageDatastoreForVms,omitempty"` - Auth *AuthInfo `json:"auth"` - NetworkConfiguration *NetworkConfiguration `json:"networkConfiguration"` - Kind string `json:"kind"` - SyslogEndpoint string `json:"syslogEndpoint,omitempty"` - Stats *StatsInfo `json:"stats,omitempty"` - State string `json:"state"` - ID string `json:"id"` - ImageDatastores []string `json:"imageDatastores"` - SelfLink string `json:"selfLink"` - Migration *MigrationStatus `json:"migrationStatus,omitempty"` - ServiceConfigurations []ServiceConfiguration `json:"serviceConfigurations,omitempty"` - LoadBalancerEnabled bool `json:"loadBalancerEnabled"` - LoadBalancerAddress string `json:"loadBalancerAddress"` -} - -// Represents multiple deployments returned by the API. -type Deployments struct { - Items []Deployment `json:"items"` -} - -// Represents source load balacer address to migrate deployment -type InitializeMigrationOperation struct { - SourceNodeGroupReference string `json:"sourceNodeGroupReference"` -} - -// Represents source load balacer address to finish migration of deployment -type FinalizeMigrationOperation struct { - SourceNodeGroupReference string `json:"sourceNodeGroupReference"` -} - -// Represents stats information -type StatsInfo struct { - Enabled bool `json:"enabled,omitempty"` - StoreEndpoint string `json:"storeEndpoint,omitempty"` - StorePort int `json:"storePort,omitempty"` -} - -// Represents authentication information -type AuthInfo struct { - Password string `json:"password,omitempty"` - Endpoint string `json:"endpoint,omitempty"` - Tenant string `json:"tenant,omitempty"` - Port int `json:"port,omitempty"` - SecurityGroups []string `json:"securityGroups,omitempty"` - Username string `json:"username,omitempty"` -} - -// Represents ip range -type IpRange struct { - Start string `json:"start,omitempty"` - End string `json:"end,omitempty"` -} - -// Represents creation spec for network configuration. -type NetworkConfigurationCreateSpec struct { - Enabled bool `json:"sdnEnabled,omitempty"` - Address string `json:"networkManagerAddress,omitempty"` - Username string `json:"networkManagerUsername,omitempty"` - Password string `json:"networkManagerPassword,omitempty"` - NetworkZoneId string `json:"networkZoneId,omitempty"` - TopRouterId string `json:"networkTopRouterId,omitempty"` - EdgeIpPoolId string `json:"networkEdgeIpPoolId,omitempty"` - HostUplinkPnic string `json:"networkHostUplinkPnic,omitempty"` - IpRange string `json:"ipRange,omitempty"` - ExternalIpRange *IpRange `json:"externalIpRange,omitempty"` - DhcpServers []string `json:"dhcpServers,omitempty"` -} - -// Represents network configuration. -type NetworkConfiguration struct { - Enabled bool `json:"sdnEnabled,omitempty"` - Address string `json:"networkManagerAddress,omitempty"` - Username string `json:"networkManagerUsername,omitempty"` - Password string `json:"networkManagerPassword,omitempty"` - NetworkZoneId string `json:"networkZoneId,omitempty"` - TopRouterId string `json:"networkTopRouterId,omitempty"` - EdgeIpPoolId string `json:"networkEdgeIpPoolId,omitempty"` - HostUplinkPnic string `json:"networkHostUplinkPnic,omitempty"` - IpRange string `json:"ipRange,omitempty"` - FloatingIpRange *IpRange `json:"floatingIpRange,omitempty"` - SnatIp string `json:"snatIp,omitempty"` - DhcpServers []string `json:"dhcpServers,omitempty"` -} - -// Creation spec for networks. -type NetworkCreateSpec struct { - Name string `json:"name"` - Description string `json:"description,omitempty"` - PortGroups []string `json:"portGroups"` -} - -// Represents a subnet -type Network struct { - Kind string `json:"kind"` - Name string `json:"name"` - Description string `json:"description,omitempty"` - State string `json:"state"` - ID string `json:"id"` - PortGroups []string `json:"portGroups"` - Tags []string `json:"tags,omitempty"` - SelfLink string `json:"selfLink"` - IsDefault bool `json:"isDefault"` -} - -// Represents multiple subnets returned by the API -type Networks struct { - Items []Network `json:"items"` -} - -// Create spec for virtual subnet -type VirtualSubnetCreateSpec struct { - Name string `json:"name"` - Description string `json:"description,omitempty"` - RoutingType string `json:"routingType"` - Size int `json:"size"` - ReservedStaticIpSize int `json:"reservedStaticIpSize,omitempty"` -} - -// Represents a virtual network -type VirtualSubnet struct { - ID string `json:"id"` - Name string `json:"name"` - Description string `json:"description,omitempty"` - State string `json:"state"` - RoutingType string `json:"routingType"` - IsDefault bool `json:"isDefault"` - Cidr string `json:"cidr,omitempty"` - LowIpDynamic string `json:"lowIpDynamic,omitempty"` - HighIpDynamic string `json:"highIpDynamic,omitempty"` - LowIpStatic string `json:"lowIpStatic,omitempty"` - HighIpStatic string `json:"highIpStatic,omitempty"` - ReservedIpList []string `json:"reservedIpList"` - SelfLink string `json:"selfLink"` -} - -// Represents multiple virtual subnets returned -type VirtualSubnets struct { - Items []VirtualSubnet `json:"items"` -} - -// Represents a router -type Router struct { - ID string `json:"id"` - Kind string `json:"kind"` - Name string `json:"name"` - PrivateIpCidr string `json:"privateIpCidr"` -} - -// Represents multiple routers returned by the API. -type Routers struct { - Items []Router `json:"items"` -} - -type RouterCreateSpec struct { - Name string `json:"name"` - PrivateIpCidr string `json:"privateIpCidr"` -} - -// Represents name that can be set for router -type RouterUpdateSpec struct { - RouterName string `json:"name"` -} - -// Creation spec for Service Configuration. -type ServiceConfigurationSpec struct { - Type string `json:"type"` - ImageID string `json:"imageId"` -} - -// Represnts a Service configuration. -type ServiceConfiguration struct { - Kind string `json:"kind"` - Type string `json:"type"` - ImageID string `json:"imageId"` -} - -// Creation spec for services. -type ServiceCreateSpec struct { - Name string `json:"name"` - Type string `json:"type"` - VMFlavor string `json:"vmFlavor,omitempty"` - MasterVmFlavor string `json:"masterVmFlavor,omitempty"` - WorkerVmFlavor string `json:"workerVmFlavor,omitempty"` - DiskFlavor string `json:"diskFlavor,omitempty"` - NetworkID string `json:"vmNetworkId,omitempty"` - ImageID string `json:"imageId,omitempty"` - WorkerCount int `json:"workerCount"` - BatchSizeWorker int `json:"workerBatchExpansionSize,omitempty"` - ExtendedProperties map[string]string `json:"extendedProperties"` -} - -// Represents a service -type Service struct { - Kind string `json:"kind"` - Name string `json:"name"` - State string `json:"state"` - ID string `json:"id"` - Type string `json:"type"` - ProjectID string `json:"projectID,omitempty"` - WorkerCount int `json:"workerCount"` - SelfLink string `json:"selfLink,omitempty"` - ErrorReason string `json:"errorReason,omitempty"` - ExtendedProperties map[string]string `json:"extendedProperties"` -} - -// Represents multiple services returned by the API -type Services struct { - Items []Service `json:"items"` -} - -// Represents service size that can be resized for service -type ServiceResizeOperation struct { - NewWorkerCount int `json:"newWorkerCount"` -} - -// Represents service imageId that can be updated during change version -type ServiceChangeVersionOperation struct { - NewImageID string `json:"newImageId"` -} - -// Represents a security group -type SecurityGroup struct { - Name string `json:"name"` - Inherited bool `json:"inherited"` -} - -// Represents set_security_groups spec -type SecurityGroupsSpec struct { - Items []string `json:"items"` -} - -// Represents single availability zone. -type AvailabilityZone struct { - Kind string `json:"kind"` - Name string `json:"name"` - State string `json:"state"` - ID string `json:"id"` - SelfLink string `json:"selfLink"` -} - -// Represents multiple availability zones returned by the API. -type AvailabilityZones struct { - Items []AvailabilityZone `json:"items"` -} - -// Creation spec for availability zones. -type AvailabilityZoneCreateSpec struct { - Name string `json:"name"` -} - -// Represents availability zone that can be set for host -type HostSetAvailabilityZoneOperation struct { - AvailabilityZoneId string `json:"availabilityZoneId"` -} - -// Represents the list of image datastores. -type ImageDatastores struct { - Items []string `json:"items"` -} - -// Image creation spec. -type ImageCreateSpec struct { - Name string `json:"name"` - ReplicationType string `json:"replicationType"` -} - -// Represents deployment info -type Info struct { - BaseVersion string `json:"baseVersion"` - FullVersion string `json:"fullVersion"` - GitCommitHash string `json:"gitCommitHash"` - NetworkType string `json:"networkType"` -} - -// NSX configuration spec -type NsxConfigurationSpec struct { - NsxAddress string `json:"nsxAddress"` - NsxUsername string `json:"nsxUsername"` - NsxPassword string `json:"nsxPassword"` - DhcpServerAddresses map[string]string `json:"dhcpServerAddresses"` - PrivateIpRootCidr string `json:"privateIpRootCidr"` - FloatingIpRootRange IpRange `json:"floatingIpRootRange"` - T0RouterId string `json:"t0RouterId"` - EdgeClusterId string `json:"edgeClusterId"` - OverlayTransportZoneId string `json:"overlayTransportZoneId"` - TunnelIpPoolId string `json:"tunnelIpPoolId"` - HostUplinkPnic string `json:"hostUplinkPnic"` - HostUplinkVlanId int `json:"hostUplinkVlanId"` -} - -// Represents a subnet -type Subnet struct { - ID string `json:"id"` - Kind string `json:"kind"` - Name string `json:"name"` - Description string `json:"description,omitempty"` - PrivateIpCidr string `json:"privateIpCidr"` - ReservedIps map[string]string `json:"reservedIps"` - State string `json:"state"` -} - -// Represents multiple subnets returned by the API. -type Subnets struct { - Items []Subnet `json:"items"` -} - -// Creation spec for subnets. -type SubnetCreateSpec struct { - Name string `json:"name"` - Description string `json:"description"` - PrivateIpCidr string `json:"privateIpCidr"` -} - -// Represents name that can be set for subnet -type SubnetUpdateSpec struct { - SubnetName string `json:"name"` -} - -// Identity and Access Management (IAM) -// IAM Policy entry -type PolicyEntry struct { - Principal string `json:"principal"` - Roles []string `json:"roles"` -} - -type PolicyDelta struct { - Principal string `json:"principal"` - Action string `json:"action"` - Role string `json:"role"` -} diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/auth.go b/vendor/github.com/vmware/photon-controller-go-sdk/photon/auth.go deleted file mode 100644 index db68073f126..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/auth.go +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (c) 2016 VMware, Inc. All Rights Reserved. -// -// This product is licensed to you under the Apache License, Version 2.0 (the "License"). -// You may not use this product except in compliance with the License. -// -// This product may include a number of subcomponents with separate copyright notices and -// license terms. Your use of these subcomponents is subject to the terms and conditions -// of the subcomponent's license, as noted in the LICENSE file. - -package photon - -import ( - "encoding/json" - "fmt" - - "github.com/vmware/photon-controller-go-sdk/photon/lightwave" -) - -// Contains functionality for auth API. -type AuthAPI struct { - client *Client -} - -const authUrl string = rootUrl + "/auth" - -// Gets authentication info. -func (api *AuthAPI) Get() (info *AuthInfo, err error) { - res, err := api.client.restClient.Get(api.client.Endpoint+authUrl, nil) - if err != nil { - return - } - defer res.Body.Close() - res, err = getError(res) - if err != nil { - return - } - info = &AuthInfo{} - err = json.NewDecoder(res.Body).Decode(info) - return -} - -// Gets Tokens from username/password. -func (api *AuthAPI) GetTokensByPassword(username string, password string) (tokenOptions *TokenOptions, err error) { - oidcClient, err := api.buildOIDCClient() - if err != nil { - return - } - - tokenResponse, err := oidcClient.GetTokenByPasswordGrant(username, password) - if err != nil { - return - } - - return api.toTokenOptions(tokenResponse), nil -} - -// GetTokensFromWindowsLogInContext gets tokens based on Windows logged in context -// In case of running on platform other than Windows, it returns error -func (api *AuthAPI) GetTokensFromWindowsLogInContext() (tokenOptions *TokenOptions, err error) { - oidcClient, err := api.buildOIDCClient() - if err != nil { - return - } - - tokenResponse, err := oidcClient.GetTokensFromWindowsLogInContext() - if err != nil { - return - } - - return api.toTokenOptions(tokenResponse), nil -} - -// Gets tokens from refresh token. -func (api *AuthAPI) GetTokensByRefreshToken(refreshtoken string) (tokenOptions *TokenOptions, err error) { - oidcClient, err := api.buildOIDCClient() - if err != nil { - return - } - - tokenResponse, err := oidcClient.GetTokenByRefreshTokenGrant(refreshtoken) - if err != nil { - return - } - - return api.toTokenOptions(tokenResponse), nil -} - -func (api *AuthAPI) getAuthEndpoint() (endpoint string, err error) { - authInfo, err := api.client.Auth.Get() - if err != nil { - return - } - - if authInfo.Port == 0 { - authInfo.Port = 443 - } - - return fmt.Sprintf("https://%s:%d", authInfo.Endpoint, authInfo.Port), nil -} - -func (api *AuthAPI) buildOIDCClient() (client *lightwave.OIDCClient, err error) { - authEndPoint, err := api.getAuthEndpoint() - if err != nil { - return - } - - return lightwave.NewOIDCClient( - authEndPoint, - api.buildOIDCClientOptions(&api.client.options), - api.client.restClient.logger), nil -} - -const tokenScope string = "openid offline_access rs_photon_platform at_groups" - -func (api *AuthAPI) buildOIDCClientOptions(options *ClientOptions) *lightwave.OIDCClientOptions { - return &lightwave.OIDCClientOptions{ - IgnoreCertificate: api.client.options.IgnoreCertificate, - RootCAs: api.client.options.RootCAs, - TokenScope: tokenScope, - } -} - -func (api *AuthAPI) toTokenOptions(response *lightwave.OIDCTokenResponse) *TokenOptions { - return &TokenOptions{ - AccessToken: response.AccessToken, - ExpiresIn: response.ExpiresIn, - RefreshToken: response.RefreshToken, - IdToken: response.IdToken, - TokenType: response.TokenType, - } -} - -// Parse the given token details. -func (api *AuthAPI) parseTokenDetails(token string) (jwtToken *lightwave.JWTToken, err error) { - jwtToken = lightwave.ParseTokenDetails(token) - return jwtToken, nil -} - -// Parse the given token raw details. -func (api *AuthAPI) parseRawTokenDetails(token string) (jwtToken []string, err error) { - jwtToken, err = lightwave.ParseRawTokenDetails(token) - return jwtToken, err -} diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/availabilityzones.go b/vendor/github.com/vmware/photon-controller-go-sdk/photon/availabilityzones.go deleted file mode 100644 index 338ce4dc761..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/availabilityzones.go +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (c) 2016 VMware, Inc. All Rights Reserved. -// -// This product is licensed to you under the Apache License, Version 2.0 (the "License"). -// You may not use this product except in compliance with the License. -// -// This product may include a number of subcomponents with separate copyright notices and -// license terms. Your use of these subcomponents is subject to the terms and conditions -// of the subcomponent's license, as noted in the LICENSE file. - -package photon - -import ( - "bytes" - "encoding/json" -) - -// Contains functionality for availability zones API. -type AvailabilityZonesAPI struct { - client *Client -} - -var availabilityzoneUrl string = rootUrl + "/availabilityzones" - -// Creates availability zone. -func (api *AvailabilityZonesAPI) Create(availabilityzoneSpec *AvailabilityZoneCreateSpec) (task *Task, err error) { - body, err := json.Marshal(availabilityzoneSpec) - if err != nil { - return - } - res, err := api.client.restClient.Post( - api.client.Endpoint+availabilityzoneUrl, - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Gets availability zone with the specified ID. -func (api *AvailabilityZonesAPI) Get(id string) (availabilityzone *AvailabilityZone, err error) { - res, err := api.client.restClient.Get(api.getEntityUrl(id), api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - res, err = getError(res) - if err != nil { - return - } - availabilityzone = &AvailabilityZone{} - err = json.NewDecoder(res.Body).Decode(availabilityzone) - return -} - -// Returns all availability zones on an photon instance. -func (api *AvailabilityZonesAPI) GetAll() (result *AvailabilityZones, err error) { - uri := api.client.Endpoint + availabilityzoneUrl - res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions) - if err != nil { - return - } - - result = &AvailabilityZones{} - err = json.Unmarshal(res, result) - return -} - -// Deletes the availability zone with specified ID. -func (api *AvailabilityZonesAPI) Delete(id string) (task *Task, err error) { - res, err := api.client.restClient.Delete(api.client.Endpoint+availabilityzoneUrl+"/"+id, api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Gets all tasks with the specified availability zone ID, using options to filter the results. -// If options is nil, no filtering will occur. -func (api *AvailabilityZonesAPI) GetTasks(id string, options *TaskGetOptions) (result *TaskList, err error) { - uri := api.client.Endpoint + availabilityzoneUrl + "/" + id + "/tasks" - if options != nil { - uri += getQueryString(options) - } - res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions) - if err != nil { - return - } - - result = &TaskList{} - err = json.Unmarshal(res, result) - return -} - -func (api *AvailabilityZonesAPI) getEntityUrl(id string) (url string) { - return api.client.Endpoint + availabilityzoneUrl + "/" + id -} diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/client.go b/vendor/github.com/vmware/photon-controller-go-sdk/photon/client.go deleted file mode 100644 index fb48c59820b..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/client.go +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright (c) 2016 VMware, Inc. All Rights Reserved. -// -// This product is licensed to you under the Apache License, Version 2.0 (the "License"). -// You may not use this product except in compliance with the License. -// -// This product may include a number of subcomponents with separate copyright notices and -// license terms. Your use of these subcomponents is subject to the terms and conditions -// of the subcomponent's license, as noted in the LICENSE file. - -package photon - -import ( - "crypto/tls" - "crypto/x509" - "io/ioutil" - "log" - "net/http" - "strings" - "time" -) - -// Represents stateless context needed to call photon APIs. -type Client struct { - options ClientOptions - restClient *restClient - logger *log.Logger - Endpoint string - Status *StatusAPI - Tenants *TenantsAPI - Tasks *TasksAPI - Projects *ProjectsAPI - Flavors *FlavorsAPI - Images *ImagesAPI - Disks *DisksAPI - VMs *VmAPI - Hosts *HostsAPI - Deployments *DeploymentsAPI - ResourceTickets *ResourceTicketsAPI - Networks *NetworksAPI - VirtualSubnets *VirtualSubnetsAPI - Services *ServicesAPI - Auth *AuthAPI - AvailabilityZones *AvailabilityZonesAPI - Info *InfoAPI - Routers *RoutersAPI - Subnets *SubnetsAPI -} - -// Represents Tokens -type TokenOptions struct { - AccessToken string `json:"access_token"` - ExpiresIn int `json:"expires_in"` - RefreshToken string `json:"refresh_token,omitempty"` - IdToken string `json:"id_token"` - TokenType string `json:"token_type"` -} - -type TokenCallback func(string) - -// Options for Client -type ClientOptions struct { - // When using the Tasks.Wait APIs, defines the duration of how long - // the SDK should continue to poll the server. Default is 30 minutes. - // TasksAPI.WaitTimeout() can be used to specify timeout on - // individual calls. - TaskPollTimeout time.Duration - - // Whether or not to ignore any TLS errors when talking to photon, - // false by default. - IgnoreCertificate bool - - // List of root CA's to use for server validation - // nil by default. - RootCAs *x509.CertPool - - // For tasks APIs, defines the delay between each polling attempt. - // Default is 100 milliseconds. - TaskPollDelay time.Duration - - // For tasks APIs, defines the number of retries to make in the event - // of an error. Default is 3. - TaskRetryCount int - - // Tokens for user authentication. Default is empty. - TokenOptions *TokenOptions - - // A function to be called if the access token was refreshed - // The client can save the new access token for future API - // calls so that it doesn't need to be refreshed again. - UpdateAccessTokenCallback TokenCallback -} - -// Creates a new photon client with specified options. If options -// is nil, default options will be used. -func NewClient(endpoint string, options *ClientOptions, logger *log.Logger) (c *Client) { - defaultOptions := &ClientOptions{ - TaskPollTimeout: 30 * time.Minute, - TaskPollDelay: 100 * time.Millisecond, - TaskRetryCount: 3, - TokenOptions: &TokenOptions{}, - IgnoreCertificate: false, - RootCAs: nil, - } - - if options != nil { - if options.TaskPollTimeout != 0 { - defaultOptions.TaskPollTimeout = options.TaskPollTimeout - } - if options.TaskPollDelay != 0 { - defaultOptions.TaskPollDelay = options.TaskPollDelay - } - if options.TaskRetryCount != 0 { - defaultOptions.TaskRetryCount = options.TaskRetryCount - } - if options.TokenOptions != nil { - defaultOptions.TokenOptions = options.TokenOptions - } - if options.RootCAs != nil { - defaultOptions.RootCAs = options.RootCAs - } - defaultOptions.IgnoreCertificate = options.IgnoreCertificate - defaultOptions.UpdateAccessTokenCallback = options.UpdateAccessTokenCallback - } - - if logger == nil { - logger = createPassThroughLogger() - } - - tr := &http.Transport{ - TLSClientConfig: &tls.Config{ - InsecureSkipVerify: defaultOptions.IgnoreCertificate, - RootCAs: defaultOptions.RootCAs}, - } - - endpoint = strings.TrimRight(endpoint, "/") - - tokenCallback := func(newToken string) { - c.options.TokenOptions.AccessToken = newToken - if c.options.UpdateAccessTokenCallback != nil { - c.options.UpdateAccessTokenCallback(newToken) - } - } - - restClient := &restClient{ - httpClient: &http.Client{Transport: tr}, - logger: logger, - UpdateAccessTokenCallback: tokenCallback, - } - - c = &Client{Endpoint: endpoint, restClient: restClient, logger: logger} - - // Ensure a copy of options is made, rather than using a pointer - // which may change out from underneath if misused by the caller. - c.options = *defaultOptions - c.Status = &StatusAPI{c} - c.Tenants = &TenantsAPI{c} - c.Tasks = &TasksAPI{c} - c.Projects = &ProjectsAPI{c} - c.Flavors = &FlavorsAPI{c} - c.Images = &ImagesAPI{c} - c.Disks = &DisksAPI{c} - c.VMs = &VmAPI{c} - c.Hosts = &HostsAPI{c} - c.Deployments = &DeploymentsAPI{c} - c.ResourceTickets = &ResourceTicketsAPI{c} - c.Networks = &NetworksAPI{c} - c.VirtualSubnets = &VirtualSubnetsAPI{c} - c.Services = &ServicesAPI{c} - c.Auth = &AuthAPI{c} - c.AvailabilityZones = &AvailabilityZonesAPI{c} - c.Info = &InfoAPI{c} - c.Routers = &RoutersAPI{c} - c.Subnets = &SubnetsAPI{c} - - // Tell the restClient about the Auth API so it can request new - // acces tokens when they expire - restClient.Auth = c.Auth - return -} - -// Creates a new photon client with specified options and http.Client. -// Useful for functional testing where http calls must be mocked out. -// If options is nil, default options will be used. -func NewTestClient(endpoint string, options *ClientOptions, httpClient *http.Client) (c *Client) { - c = NewClient(endpoint, options, nil) - c.restClient.httpClient = httpClient - return -} - -func createPassThroughLogger() (l *log.Logger) { - // ioutil.Discard makes all logging operation be a no-op. - return log.New(ioutil.Discard, "", log.LstdFlags) -} diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/deployments.go b/vendor/github.com/vmware/photon-controller-go-sdk/photon/deployments.go deleted file mode 100644 index a88c0b9c6b8..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/deployments.go +++ /dev/null @@ -1,337 +0,0 @@ -// Copyright (c) 2016 VMware, Inc. All Rights Reserved. -// -// This product is licensed to you under the Apache License, Version 2.0 (the "License"). -// You may not use this product except in compliance with the License. -// -// This product may include a number of subcomponents with separate copyright notices and -// license terms. Your use of these subcomponents is subject to the terms and conditions -// of the subcomponent's license, as noted in the LICENSE file. - -package photon - -import ( - "bytes" - "encoding/json" -) - -// Contains functionality for deployments API. -type DeploymentsAPI struct { - client *Client -} - -var deploymentUrl string = rootUrl + "/deployments" - -// Creates a deployment -func (api *DeploymentsAPI) Create(deploymentSpec *DeploymentCreateSpec) (task *Task, err error) { - body, err := json.Marshal(deploymentSpec) - if err != nil { - return - } - res, err := api.client.restClient.Post( - api.client.Endpoint+deploymentUrl, - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Deletes a deployment with specified ID. -func (api *DeploymentsAPI) Delete(id string) (task *Task, err error) { - res, err := api.client.restClient.Delete(api.getEntityUrl(id), api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Deploys a deployment with specified ID. -func (api *DeploymentsAPI) Deploy(id string, config *DeploymentDeployOperation) (task *Task, err error) { - body, err := json.Marshal(config) - if err != nil { - return - } - - res, err := api.client.restClient.Post( - api.getEntityUrl(id)+"/deploy", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Destroys a deployment with specified ID. -func (api *DeploymentsAPI) Destroy(id string) (task *Task, err error) { - res, err := api.client.restClient.Post( - api.getEntityUrl(id)+"/destroy", - "application/json", - bytes.NewReader([]byte("")), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Returns all deployments. -func (api *DeploymentsAPI) GetAll() (result *Deployments, err error) { - res, err := api.client.restClient.Get(api.client.Endpoint+deploymentUrl, api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - res, err = getError(res) - if err != nil { - return - } - result = &Deployments{} - err = json.NewDecoder(res.Body).Decode(result) - return -} - -// Gets a deployment with the specified ID. -func (api *DeploymentsAPI) Get(id string) (deployment *Deployment, err error) { - res, err := api.client.restClient.Get(api.getEntityUrl(id), api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - res, err = getError(res) - if err != nil { - return - } - var result Deployment - err = json.NewDecoder(res.Body).Decode(&result) - return &result, nil -} - -// Gets all hosts with the specified deployment ID. -func (api *DeploymentsAPI) GetHosts(id string) (result *Hosts, err error) { - uri := api.getEntityUrl(id) + "/hosts" - res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions) - if err != nil { - return - } - - result = &Hosts{} - err = json.Unmarshal(res, result) - return -} - -// Gets all the vms with the specified deployment ID. -func (api *DeploymentsAPI) GetVms(id string) (result *VMs, err error) { - uri := api.getEntityUrl(id) + "/vms" - res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions) - if err != nil { - return - } - - result = &VMs{} - err = json.Unmarshal(res, result) - return -} - -// Initialize deployment migration from source to destination -func (api *DeploymentsAPI) InitializeDeploymentMigration(sourceAddress *InitializeMigrationOperation, id string) (task *Task, err error) { - body, err := json.Marshal(sourceAddress) - if err != nil { - return - } - res, err := api.client.restClient.Post( - api.getEntityUrl(id)+"/initialize_migration", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Finalize deployment migration from source to destination -func (api *DeploymentsAPI) FinalizeDeploymentMigration(sourceAddress *FinalizeMigrationOperation, id string) (task *Task, err error) { - body, err := json.Marshal(sourceAddress) - if err != nil { - return - } - res, err := api.client.restClient.Post( - api.getEntityUrl(id)+"/finalize_migration", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -func (api *DeploymentsAPI) SetSecurityGroups(id string, securityGroups *SecurityGroupsSpec) (*Task, error) { - return setSecurityGroups(api.client, api.getEntityUrl(id), securityGroups) -} - -// Update image datastores of a deployment. -func (api *DeploymentsAPI) SetImageDatastores(id string, imageDatastores *ImageDatastores) (task *Task, err error) { - body, err := json.Marshal(imageDatastores) - if err != nil { - return - } - - res, err := api.client.restClient.Post( - api.getEntityUrl(id)+"/set_image_datastores", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - - task, err = getTask(getError(res)) - return -} - -// Synchronizes hosts configurations -func (api *DeploymentsAPI) SyncHostsConfig(id string) (task *Task, err error) { - res, err := api.client.restClient.Post( - api.getEntityUrl(id)+"/sync_hosts_config", - "application/json", - bytes.NewReader([]byte("")), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - - task, err = getTask(getError(res)) - return -} - -// Pause system with specified deployment ID. -func (api *DeploymentsAPI) PauseSystem(id string) (task *Task, err error) { - res, err := api.client.restClient.Post( - api.getEntityUrl(id)+"/pause_system", - "application/json", - bytes.NewReader([]byte("")), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - - task, err = getTask(getError(res)) - return -} - -// Pause background tasks of system with specified deployment ID. -func (api *DeploymentsAPI) PauseBackgroundTasks(id string) (task *Task, err error) { - res, err := api.client.restClient.Post( - api.getEntityUrl(id)+"/pause_background_tasks", - "application/json", - bytes.NewReader([]byte("")), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - - task, err = getTask(getError(res)) - return -} - -// Pause background tasks of system with specified deployment ID. -func (api *DeploymentsAPI) ResumeSystem(id string) (task *Task, err error) { - res, err := api.client.restClient.Post( - api.getEntityUrl(id)+"/resume_system", - "application/json", - bytes.NewReader([]byte("")), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - - task, err = getTask(getError(res)) - return -} - -// Enable service type with specified deployment ID. -func (api *DeploymentsAPI) EnableServiceType(id string, serviceConfigSpec *ServiceConfigurationSpec) (task *Task, err error) { - body, err := json.Marshal(serviceConfigSpec) - if err != nil { - return - } - res, err := api.client.restClient.Post( - api.getEntityUrl(id)+"/enable_service_type", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - - task, err = getTask(getError(res)) - return -} - -// Disable service type with specified deployment ID. -func (api *DeploymentsAPI) DisableServiceType(id string, serviceConfigSpec *ServiceConfigurationSpec) (task *Task, err error) { - body, err := json.Marshal(serviceConfigSpec) - if err != nil { - return - } - res, err := api.client.restClient.Post( - api.getEntityUrl(id)+"/disable_service_type", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - - task, err = getTask(getError(res)) - return -} - -// Configure NSX. -func (api *DeploymentsAPI) ConfigureNsx(id string, nsxConfigSpec *NsxConfigurationSpec) (task *Task, err error) { - body, err := json.Marshal(nsxConfigSpec) - if err != nil { - return - } - - res, err := api.client.restClient.Post( - api.getEntityUrl(id)+"/configure_nsx", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - - task, err = getTask(getError(res)) - return -} - -func (api *DeploymentsAPI) getEntityUrl(id string) (url string) { - return api.client.Endpoint + deploymentUrl + "/" + id -} diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/disks.go b/vendor/github.com/vmware/photon-controller-go-sdk/photon/disks.go deleted file mode 100644 index 3bd2d8bc496..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/disks.go +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) 2016 VMware, Inc. All Rights Reserved. -// -// This product is licensed to you under the Apache License, Version 2.0 (the "License"). -// You may not use this product except in compliance with the License. -// -// This product may include a number of subcomponents with separate copyright notices and -// license terms. Your use of these subcomponents is subject to the terms and conditions -// of the subcomponent's license, as noted in the LICENSE file. - -package photon - -import ( - "encoding/json" -) - -// Contains functionality for disks API. -type DisksAPI struct { - client *Client -} - -var diskUrl string = rootUrl + "/disks/" - -// Gets a PersistentDisk for the disk with specified ID. -func (api *DisksAPI) Get(diskID string) (disk *PersistentDisk, err error) { - res, err := api.client.restClient.Get(api.client.Endpoint+diskUrl+diskID, api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - res, err = getError(res) - if err != nil { - return - } - disk = &PersistentDisk{} - err = json.NewDecoder(res.Body).Decode(disk) - return -} - -// Deletes a disk with the specified ID. -func (api *DisksAPI) Delete(diskID string) (task *Task, err error) { - res, err := api.client.restClient.Delete(api.client.Endpoint+diskUrl+diskID, api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Gets all tasks with the specified disk ID, using options to filter the results. -// If options is nil, no filtering will occur. -func (api *DisksAPI) GetTasks(id string, options *TaskGetOptions) (result *TaskList, err error) { - uri := api.client.Endpoint + diskUrl + id + "/tasks" - if options != nil { - uri += getQueryString(options) - } - res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions) - if err != nil { - return - } - - result = &TaskList{} - err = json.Unmarshal(res, result) - return -} diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/flavors.go b/vendor/github.com/vmware/photon-controller-go-sdk/photon/flavors.go deleted file mode 100644 index e6bbea8dbfc..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/flavors.go +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (c) 2016 VMware, Inc. All Rights Reserved. -// -// This product is licensed to you under the Apache License, Version 2.0 (the "License"). -// You may not use this product except in compliance with the License. -// -// This product may include a number of subcomponents with separate copyright notices and -// license terms. Your use of these subcomponents is subject to the terms and conditions -// of the subcomponent's license, as noted in the LICENSE file. - -package photon - -import ( - "bytes" - "encoding/json" -) - -// Contains functionality for flavors API. -type FlavorsAPI struct { - client *Client -} - -// Options used for find/get APIs -type FlavorGetOptions struct { - Name string `urlParam:"name"` - Kind string `urlParam:"kind"` -} - -var flavorUrl string = rootUrl + "/flavors" - -// Creates a flavor. -func (api *FlavorsAPI) Create(spec *FlavorCreateSpec) (task *Task, err error) { - body, err := json.Marshal(spec) - if err != nil { - return - } - res, err := api.client.restClient.Post( - api.client.Endpoint+flavorUrl, - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Gets details of flavor with specified ID. -func (api *FlavorsAPI) Get(flavorID string) (flavor *Flavor, err error) { - res, err := api.client.restClient.Get(api.client.Endpoint+flavorUrl+"/"+flavorID, api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - res, err = getError(res) - if err != nil { - return - } - flavor = &Flavor{} - err = json.NewDecoder(res.Body).Decode(flavor) - return -} - -// Gets flavors using options to filter results. Returns all flavors if options is nil. -func (api *FlavorsAPI) GetAll(options *FlavorGetOptions) (flavors *FlavorList, err error) { - uri := api.client.Endpoint + flavorUrl - if options != nil { - uri += getQueryString(options) - } - res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions) - if err != nil { - return - } - - flavors = &FlavorList{} - err = json.Unmarshal(res, flavors) - return -} - -// Deletes flavor with specified ID. -func (api *FlavorsAPI) Delete(flavorID string) (task *Task, err error) { - res, err := api.client.restClient.Delete(api.client.Endpoint+flavorUrl+"/"+flavorID, api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Gets all tasks with the specified flavor ID, using options to filter the results. -// If options is nil, no filtering will occur. -func (api *FlavorsAPI) GetTasks(id string, options *TaskGetOptions) (result *TaskList, err error) { - uri := api.client.Endpoint + flavorUrl + "/" + id + "/tasks" - if options != nil { - uri += getQueryString(options) - } - - res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions) - if err != nil { - return - } - - result = &TaskList{} - err = json.Unmarshal(res, result) - return -} diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/hosts.go b/vendor/github.com/vmware/photon-controller-go-sdk/photon/hosts.go deleted file mode 100644 index 50fa097d622..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/hosts.go +++ /dev/null @@ -1,219 +0,0 @@ -// Copyright (c) 2016 VMware, Inc. All Rights Reserved. -// -// This product is licensed to you under the Apache License, Version 2.0 (the "License"). -// You may not use this product except in compliance with the License. -// -// This product may include a number of subcomponents with separate copyright notices and -// license terms. Your use of these subcomponents is subject to the terms and conditions -// of the subcomponent's license, as noted in the LICENSE file. - -package photon - -import ( - "bytes" - "encoding/json" -) - -// Contains functionality for hosts API. -type HostsAPI struct { - client *Client -} - -var hostUrl string = rootUrl + "/hosts" - -// Creates a host. -func (api *HostsAPI) Create(hostSpec *HostCreateSpec, deploymentId string) (task *Task, err error) { - body, err := json.Marshal(hostSpec) - if err != nil { - return - } - res, err := api.client.restClient.Post( - api.client.Endpoint+deploymentUrl+"/"+deploymentId+"/hosts", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Deletes a host with specified ID. -func (api *HostsAPI) Delete(id string) (task *Task, err error) { - res, err := api.client.restClient.Delete(api.client.Endpoint+hostUrl+"/"+id, api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Returns all hosts -func (api *HostsAPI) GetAll() (result *Hosts, err error) { - res, err := api.client.restClient.Get(api.client.Endpoint+hostUrl, api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - res, err = getError(res) - if err != nil { - return - } - result = &Hosts{} - err = json.NewDecoder(res.Body).Decode(result) - return -} - -// Gets a host with the specified ID. -func (api *HostsAPI) Get(id string) (host *Host, err error) { - res, err := api.client.restClient.Get(api.client.Endpoint+hostUrl+"/"+id, api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - res, err = getError(res) - if err != nil { - return - } - var result Host - err = json.NewDecoder(res.Body).Decode(&result) - return &result, nil -} - -// Sets host's availability zone. -func (api *HostsAPI) SetAvailabilityZone(id string, availabilityZone *HostSetAvailabilityZoneOperation) (task *Task, err error) { - body, err := json.Marshal(availabilityZone) - if err != nil { - return - } - - res, err := api.client.restClient.Post( - api.client.Endpoint+hostUrl+"/"+id+"/set_availability_zone", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - - if err != nil { - return - } - - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Gets all tasks with the specified host ID, using options to filter the results. -// If options is nil, no filtering will occur. -func (api *HostsAPI) GetTasks(id string, options *TaskGetOptions) (result *TaskList, err error) { - uri := api.client.Endpoint + hostUrl + "/" + id + "/tasks" - if options != nil { - uri += getQueryString(options) - } - res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions) - if err != nil { - return - } - - result = &TaskList{} - err = json.Unmarshal(res, result) - return -} - -// Gets all the vms with the specified host ID. -func (api *HostsAPI) GetVMs(id string) (result *VMs, err error) { - res, err := api.client.restClient.Get(api.client.Endpoint+hostUrl+"/"+id+"/vms", api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - res, err = getError(res) - if err != nil { - return - } - result = &VMs{} - err = json.NewDecoder(res.Body).Decode(result) - return -} - -// provision the host with the specified id -func (api *HostsAPI) Provision(id string) (task *Task, err error) { - body := []byte{} - res, err := api.client.restClient.Post( - api.client.Endpoint+hostUrl+"/"+id+"/provision", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Suspend the host with the specified id -func (api *HostsAPI) Suspend(id string) (task *Task, err error) { - body := []byte{} - res, err := api.client.restClient.Post( - api.client.Endpoint+hostUrl+"/"+id+"/suspend", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Resume the host with the specified id -func (api *HostsAPI) Resume(id string) (task *Task, err error) { - body := []byte{} - res, err := api.client.restClient.Post( - api.client.Endpoint+hostUrl+"/"+id+"/resume", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Host with the specified id enter maintenance mode -func (api *HostsAPI) EnterMaintenanceMode(id string) (task *Task, err error) { - body := []byte{} - res, err := api.client.restClient.Post( - api.client.Endpoint+hostUrl+"/"+id+"/enter_maintenance", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Host with the specified id exit maintenance mode -func (api *HostsAPI) ExitMaintenanceMode(id string) (task *Task, err error) { - body := []byte{} - res, err := api.client.restClient.Post( - api.client.Endpoint+hostUrl+"/"+id+"/exit_maintenance", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/images.go b/vendor/github.com/vmware/photon-controller-go-sdk/photon/images.go deleted file mode 100644 index f1e268b74ab..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/images.go +++ /dev/null @@ -1,182 +0,0 @@ -// Copyright (c) 2016 VMware, Inc. All Rights Reserved. -// -// This product is licensed to you under the Apache License, Version 2.0 (the "License"). -// You may not use this product except in compliance with the License. -// -// This product may include a number of subcomponents with separate copyright notices and -// license terms. Your use of these subcomponents is subject to the terms and conditions -// of the subcomponent's license, as noted in the LICENSE file. - -package photon - -import ( - "bytes" - "encoding/json" - "io" -) - -// Contains functionality for images API. -type ImagesAPI struct { - client *Client -} - -// Options for GetImage API. -type ImageGetOptions struct { - Name string `urlParam:"name"` -} - -var imageUrl string = rootUrl + "/images" - -// Uploads a new image, reading from the specified image path. -// If options is nil, default options are used. -func (api *ImagesAPI) CreateFromFile(imagePath string, options *ImageCreateOptions) (task *Task, err error) { - params := imageCreateOptionsToMap(options) - res, err := api.client.restClient.MultipartUploadFile(api.client.Endpoint+imageUrl, imagePath, params, api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - result, err := getTask(getError(res)) - return result, err -} - -// Uploads a new image, reading from the specified io.Reader. -// Name is a descriptive name of the image, it is used in the filename field of the Content-Disposition header, -// and does not need to be unique. -// If options is nil, default options are used. -func (api *ImagesAPI) Create(reader io.ReadSeeker, name string, options *ImageCreateOptions) (task *Task, err error) { - params := imageCreateOptionsToMap(options) - res, err := api.client.restClient.MultipartUpload(api.client.Endpoint+imageUrl, reader, name, params, api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - result, err := getTask(getError(res)) - return result, err -} - -// Gets all images on this photon instance. -func (api *ImagesAPI) GetAll(options *ImageGetOptions) (images *Images, err error) { - uri := api.client.Endpoint + imageUrl - if options != nil { - uri += getQueryString(options) - } - res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions) - if err != nil { - return - } - - images = &Images{} - err = json.Unmarshal(res, images) - return -} - -// Gets details of image with the specified ID. -func (api *ImagesAPI) Get(imageID string) (image *Image, err error) { - res, err := api.client.restClient.Get(api.client.Endpoint+imageUrl+"/"+imageID, api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - res, err = getError(res) - if err != nil { - return - } - var result Image - err = json.NewDecoder(res.Body).Decode(&result) - return &result, nil -} - -// Deletes image with the specified ID. -func (api *ImagesAPI) Delete(imageID string) (task *Task, err error) { - res, err := api.client.restClient.Delete(api.client.Endpoint+imageUrl+"/"+imageID, api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - result, err := getTask(getError(res)) - return result, err -} - -// Gets all tasks with the specified image ID, using options to filter the results. -// If options is nil, no filtering will occur. -func (api *ImagesAPI) GetTasks(id string, options *TaskGetOptions) (result *TaskList, err error) { - uri := api.client.Endpoint + imageUrl + "/" + id + "/tasks" - if options != nil { - uri += getQueryString(options) - } - - res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions) - if err != nil { - return - } - - result = &TaskList{} - err = json.Unmarshal(res, result) - return -} - -// Gets IAM Policy of an image. -func (api *ImagesAPI) GetIam(imageID string) (policy *[]PolicyEntry, err error) { - res, err := api.client.restClient.Get( - api.client.Endpoint+imageUrl+"/"+imageID+"/iam", - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - res, err = getError(res) - if err != nil { - return - } - var result []PolicyEntry - err = json.NewDecoder(res.Body).Decode(&result) - return &result, nil -} - -// Sets IAM Policy on an image. -func (api *ImagesAPI) SetIam(imageID string, policy *[]PolicyEntry) (task *Task, err error) { - body, err := json.Marshal(policy) - if err != nil { - return - } - res, err := api.client.restClient.Post( - api.client.Endpoint+imageUrl+"/"+imageID+"/iam", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Modifies IAM Policy on an image. -func (api *ImagesAPI) ModifyIam(imageID string, policyDelta *PolicyDelta) (task *Task, err error) { - body, err := json.Marshal(policyDelta) - if err != nil { - return - } - res, err := api.client.restClient.Put( - api.client.Endpoint+imageUrl+"/"+imageID+"/iam", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -func imageCreateOptionsToMap(opts *ImageCreateOptions) map[string]string { - if opts == nil { - return nil - } - return map[string]string{ - "ImageReplication": opts.ReplicationType, - } -} diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/info.go b/vendor/github.com/vmware/photon-controller-go-sdk/photon/info.go deleted file mode 100644 index ac0d9c6bd6f..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/info.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2016 VMware, Inc. All Rights Reserved. -// -// This product is licensed to you under the Apache License, Version 2.0 (the "License"). -// You may not use this product except in compliance with the License. -// -// This product may include a number of subcomponents with separate copyright notices and -// license terms. Your use of these subcomponents is subject to the terms and conditions -// of the subcomponent's license, as noted in the LICENSE file. - -package photon - -import ( - "encoding/json" -) - -type InfoAPI struct { - client *Client -} - -var infoUrl = rootUrl + "/info" - -// Get info -func (api *InfoAPI) Get() (info *Info, err error) { - res, err := api.client.restClient.Get(api.client.Endpoint+infoUrl, api.client.options.TokenOptions) - if err != nil { - return - } - - defer res.Body.Close() - - res, err = getError(res) - if err != nil { - return - } - - info = new(Info) - err = json.NewDecoder(res.Body).Decode(info) - return -} diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/lightwave/BUILD b/vendor/github.com/vmware/photon-controller-go-sdk/photon/lightwave/BUILD deleted file mode 100644 index 73158d9c4f0..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/lightwave/BUILD +++ /dev/null @@ -1,34 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -go_library( - name = "go_default_library", - srcs = [ - "jwttoken.go", - "oidcclient.go", - "oidcclient_sspi.go", - "oidcclient_sspi_unsupported.go", - ], - importmap = "k8s.io/kubernetes/vendor/github.com/vmware/photon-controller-go-sdk/photon/lightwave", - importpath = "github.com/vmware/photon-controller-go-sdk/photon/lightwave", - visibility = ["//visibility:public"], - deps = select({ - "@io_bazel_rules_go//go/platform:windows": [ - "//vendor/github.com/vmware/photon-controller-go-sdk/SSPI:go_default_library", - ], - "//conditions:default": [], - }), -) - -filegroup( - name = "package-srcs", - srcs = glob(["**"]), - tags = ["automanaged"], - visibility = ["//visibility:private"], -) - -filegroup( - name = "all-srcs", - srcs = [":package-srcs"], - tags = ["automanaged"], - visibility = ["//visibility:public"], -) diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/lightwave/jwttoken.go b/vendor/github.com/vmware/photon-controller-go-sdk/photon/lightwave/jwttoken.go deleted file mode 100644 index 9b49a0fe08c..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/lightwave/jwttoken.go +++ /dev/null @@ -1,59 +0,0 @@ -package lightwave - -import ( - "encoding/base64" - "encoding/json" - "strings" -) - -type JWTToken struct { - TokenId string `json:"jti"` - Algorithm string `json:"alg"` - Subject string `json:"sub"` - Audience []string `json:"aud"` - Groups []string `json:"groups"` - Issuer string `json:"iss"` - IssuedAt int64 `json:"iat"` - Expires int64 `json:"exp"` - Scope string `json:"scope"` - TokenType string `json:"token_type"` - TokenClass string `json:"token_class"` - Tenant string `json:"tenant"` - // It's possible to have more fields depending on how Lightwave defines the token. - // This covers all the fields we currently have. -} - -// A JSON web token is a set of Base64 encoded strings separated by a period (.) -// When decoded, it will either be JSON text or a signature -// Here we decode the strings into a single token structure. We do not parse the signature. -func ParseTokenDetails(token string) (jwtToken *JWTToken) { - jwtToken = &JWTToken{} - - chunks := strings.Split(token, ".") - for _, chunk := range chunks { - json_string, err := base64.RawURLEncoding.DecodeString(chunk) - if err == nil { - // Ignore errors. We expect that the signature is not JSON, - // so unmarshalling it will fail. That's fine. We'll extract - // all the data we can. - _ = json.Unmarshal(json_string, &jwtToken) - } - } - - return jwtToken -} - -// A JSON web token is a set of Base64 encoded strings separated by a period (.) -// When decoded, it will either be JSON text or a signature -// Here we parse the full JSON text. We do not parse the signature. -func ParseRawTokenDetails(token string) (jwtToken []string, err error) { - chunks := strings.Split(token, ".") - for _, chunk := range chunks { - jsonString, err := base64.RawURLEncoding.DecodeString(chunk) - if err == nil { - jwtToken = append(jwtToken, string(jsonString)) - } - } - - return jwtToken, err -} diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/lightwave/oidcclient.go b/vendor/github.com/vmware/photon-controller-go-sdk/photon/lightwave/oidcclient.go deleted file mode 100644 index 84647dba11d..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/lightwave/oidcclient.go +++ /dev/null @@ -1,238 +0,0 @@ -// Copyright (c) 2016 VMware, Inc. All Rights Reserved. -// -// This product is licensed to you under the Apache License, Version 2.0 (the "License"). -// You may not use this product except in compliance with the License. -// -// This product may include a number of subcomponents with separate copyright notices and -// license terms. Your use of these subcomponents is subject to the terms and conditions -// of the subcomponent's license, as noted in the LICENSE file. - -package lightwave - -import ( - "crypto/tls" - "crypto/x509" - "encoding/json" - "encoding/pem" - "fmt" - "io/ioutil" - "log" - "net/http" - "net/url" - "strings" -) - -const tokenScope string = "openid offline_access" - -type OIDCClient struct { - httpClient *http.Client - logger *log.Logger - - Endpoint string - Options *OIDCClientOptions -} - -type OIDCClientOptions struct { - // Whether or not to ignore any TLS errors when talking to photon, - // false by default. - IgnoreCertificate bool - - // List of root CA's to use for server validation - // nil by default. - RootCAs *x509.CertPool - - // The scope values to use when requesting tokens - TokenScope string -} - -func NewOIDCClient(endpoint string, options *OIDCClientOptions, logger *log.Logger) (c *OIDCClient) { - if logger == nil { - logger = log.New(ioutil.Discard, "", log.LstdFlags) - } - - options = buildOptions(options) - tr := &http.Transport{ - TLSClientConfig: &tls.Config{ - InsecureSkipVerify: options.IgnoreCertificate, - RootCAs: options.RootCAs}, - } - - c = &OIDCClient{ - httpClient: &http.Client{Transport: tr}, - logger: logger, - - Endpoint: strings.TrimRight(endpoint, "/"), - Options: options, - } - return -} - -func buildOptions(options *OIDCClientOptions) (result *OIDCClientOptions) { - result = &OIDCClientOptions{ - TokenScope: tokenScope, - } - - if options == nil { - return - } - - result.IgnoreCertificate = options.IgnoreCertificate - - if options.RootCAs != nil { - result.RootCAs = options.RootCAs - } - - if options.TokenScope != "" { - result.TokenScope = options.TokenScope - } - - return -} - -func (client *OIDCClient) buildUrl(path string) (url string) { - return fmt.Sprintf("%s%s", client.Endpoint, path) -} - -// Cert download helper - -const certDownloadPath string = "/afd/vecs/ssl" - -type lightWaveCert struct { - Value string `json:"encoded"` -} - -func (client *OIDCClient) GetRootCerts() (certList []*x509.Certificate, err error) { - // turn TLS verification off for - originalTr := client.httpClient.Transport - defer client.setTransport(originalTr) - - tr := &http.Transport{ - TLSClientConfig: &tls.Config{ - InsecureSkipVerify: true, - }, - } - client.setTransport(tr) - - // get the certs - resp, err := client.httpClient.Get(client.buildUrl(certDownloadPath)) - if err != nil { - return - } - defer resp.Body.Close() - if resp.StatusCode != 200 { - err = fmt.Errorf("Unexpected error retrieving auth server certs: %v %s", resp.StatusCode, resp.Status) - return - } - - // parse the certs - certsData := &[]lightWaveCert{} - err = json.NewDecoder(resp.Body).Decode(certsData) - if err != nil { - return - } - - certList = make([]*x509.Certificate, len(*certsData)) - for idx, cert := range *certsData { - block, _ := pem.Decode([]byte(cert.Value)) - if block == nil { - err = fmt.Errorf("Unexpected response format: %v", certsData) - return nil, err - } - - decodedCert, err := x509.ParseCertificate(block.Bytes) - if err != nil { - return nil, err - } - - certList[idx] = decodedCert - } - - return -} - -func (client *OIDCClient) setTransport(tr http.RoundTripper) { - client.httpClient.Transport = tr -} - -// Toke request helpers - -const tokenPath string = "/openidconnect/token" -const passwordGrantFormatString = "grant_type=password&username=%s&password=%s&scope=%s" -const refreshTokenGrantFormatString = "grant_type=refresh_token&refresh_token=%s" - -type OIDCTokenResponse struct { - AccessToken string `json:"access_token"` - ExpiresIn int `json:"expires_in"` - RefreshToken string `json:"refresh_token,omitempty"` - IdToken string `json:"id_token"` - TokenType string `json:"token_type"` -} - -func (client *OIDCClient) GetTokenByPasswordGrant(username string, password string) (tokens *OIDCTokenResponse, err error) { - username = url.QueryEscape(username) - password = url.QueryEscape(password) - body := fmt.Sprintf(passwordGrantFormatString, username, password, client.Options.TokenScope) - return client.getToken(body) -} - -func (client *OIDCClient) GetTokenByRefreshTokenGrant(refreshToken string) (tokens *OIDCTokenResponse, err error) { - body := fmt.Sprintf(refreshTokenGrantFormatString, refreshToken) - return client.getToken(body) -} - -func (client *OIDCClient) getToken(body string) (tokens *OIDCTokenResponse, err error) { - request, err := http.NewRequest("POST", client.buildUrl(tokenPath), strings.NewReader(body)) - if err != nil { - return nil, err - } - request.Header.Add("Content-Type", "application/x-www-form-urlencoded") - - resp, err := client.httpClient.Do(request) - if err != nil { - return nil, err - } - defer resp.Body.Close() - - err = client.checkResponse(resp) - if err != nil { - return nil, err - } - - tokens = &OIDCTokenResponse{} - err = json.NewDecoder(resp.Body).Decode(tokens) - if err != nil { - return nil, err - } - - return -} - -type OIDCError struct { - Code string `json:"error"` - Message string `json:"error_description"` -} - -func (e OIDCError) Error() string { - return fmt.Sprintf("%v: %v", e.Code, e.Message) -} - -func (client *OIDCClient) checkResponse(response *http.Response) (err error) { - if response.StatusCode/100 == 2 { - return - } - - respBody, readErr := ioutil.ReadAll(response.Body) - if err != nil { - return fmt.Errorf( - "Status: %v, Body: %v [%v]", response.Status, string(respBody[:]), readErr) - } - - var oidcErr OIDCError - err = json.Unmarshal(respBody, &oidcErr) - if err != nil { - return fmt.Errorf( - "Status: %v, Body: %v [%v]", response.Status, string(respBody[:]), readErr) - } - - return oidcErr -} diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/lightwave/oidcclient_sspi.go b/vendor/github.com/vmware/photon-controller-go-sdk/photon/lightwave/oidcclient_sspi.go deleted file mode 100644 index 9b6d8b7bd88..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/lightwave/oidcclient_sspi.go +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (c) 2017 VMware, Inc. All Rights Reserved. -// -// This product is licensed to you under the Apache License, Version 2.0 (the "License"). -// You may not use this product except in compliance with the License. -// -// This product may include a number of subcomponents with separate copyright notices and -// license terms. Your use of these subcomponents is subject to the terms and conditions -// of the subcomponent's license, as noted in the LICENSE file. - -// +build windows - -package lightwave - -import ( - "encoding/base64" - "fmt" - "github.com/vmware/photon-controller-go-sdk/SSPI" - "math/rand" - "net" - "net/url" - "strings" - "time" -) - -const gssTicketGrantFormatString = "grant_type=urn:vmware:grant_type:gss_ticket&gss_ticket=%s&context_id=%s&scope=%s" - -// GetTokensFromWindowsLogInContext gets tokens based on Windows logged in context -// Here is how it works: -// 1. Get the SPN (Service Principal Name) in the format host/FQDN of lightwave. This is needed for SSPI/Kerberos protocol -// 2. Call Windows API AcquireCredentialsHandle() using SSPI library. This will give the current users credential handle -// 3. Using this handle call Windows API AcquireCredentialsHandle(). This will give you byte[] -// 4. Encode this byte[] and send it to OIDC server over HTTP (using POST) -// 5. OIDC server can send either of the following -// - Access tokens. In this case return access tokens to client -// - Error in the format: invalid_grant: gss_continue_needed:'context id':'token from server' -// 6. In case you get error, parse it and get the token from server -// 7. Feed this token to step 3 and repeat steps till you get the access tokens from server -func (client *OIDCClient) GetTokensFromWindowsLogInContext() (tokens *OIDCTokenResponse, err error) { - spn, err := client.buildSPN() - if err != nil { - return nil, err - } - - auth, _ := SSPI.GetAuth("", "", spn, "") - - userContext, err := auth.InitialBytes() - if err != nil { - return nil, err - } - - // In case of multiple req/res between client and server (as explained in above comment), - // server needs to maintain the mapping of context id -> token - // So we need to generate random string as a context id - // If we use same context id for all the requests, results can be erroneous - contextId := client.generateRandomString() - body := fmt.Sprintf(gssTicketGrantFormatString, url.QueryEscape(base64.StdEncoding.EncodeToString(userContext)), contextId, client.Options.TokenScope) - tokens, err = client.getToken(body) - - for { - if err == nil { - break - } - - // In case of error the response will be in format: invalid_grant: gss_continue_needed:'context id':'token from server' - gssToken := client.validateAndExtractGSSResponse(err, contextId) - if gssToken == "" { - return nil, err - } - - data, err := base64.StdEncoding.DecodeString(gssToken) - if err != nil { - return nil, err - } - - userContext, err := auth.NextBytes(data) - body := fmt.Sprintf(gssTicketGrantFormatString, url.QueryEscape(base64.StdEncoding.EncodeToString(userContext)), contextId, client.Options.TokenScope) - tokens, err = client.getToken(body) - } - - return tokens, err -} - -// Gets the SPN (Service Principal Name) in the format host/FQDN of lightwave -func (client *OIDCClient) buildSPN() (spn string, err error) { - u, err := url.Parse(client.Endpoint) - if err != nil { - return "", err - } - - host, _, err := net.SplitHostPort(u.Host) - if err != nil { - return "", err - } - - addr, err := net.LookupAddr(host) - if err != nil { - return "", err - } - - var s = strings.TrimSuffix(addr[0], ".") - return "host/" + s, nil -} - -// validateAndExtractGSSResponse parse the error from server and returns token from server -// In case of error from the server, response will be in format: invalid_grant: gss_continue_needed:'context id':'token from server' -// So, we check for the above format in error and then return the token from server -// If error is not in above format, we return empty string -func (client *OIDCClient) validateAndExtractGSSResponse(err error, contextId string) string { - parts := strings.Split(err.Error(), ":") - if !(len(parts) == 4 && strings.TrimSpace(parts[1]) == "gss_continue_needed" && parts[2] == contextId) { - return "" - } else { - return parts[3] - } -} - -func (client *OIDCClient) generateRandomString() string { - const length = 10 - const asciiA = 65 - const asciiZ = 90 - rand.Seed(time.Now().UTC().UnixNano()) - bytes := make([]byte, length) - for i := 0; i < length; i++ { - bytes[i] = byte(randInt(asciiA, asciiZ)) - } - return string(bytes) -} - -func randInt(min int, max int) int { - return min + rand.Intn(max-min) -} diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/lightwave/oidcclient_sspi_unsupported.go b/vendor/github.com/vmware/photon-controller-go-sdk/photon/lightwave/oidcclient_sspi_unsupported.go deleted file mode 100644 index 3d6b6b28998..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/lightwave/oidcclient_sspi_unsupported.go +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2017 VMware, Inc. All Rights Reserved. -// -// This product is licensed to you under the Apache License, Version 2.0 (the "License"). -// You may not use this product except in compliance with the License. -// -// This product may include a number of subcomponents with separate copyright notices and -// license terms. Your use of these subcomponents is subject to the terms and conditions -// of the subcomponent's license, as noted in the LICENSE file. - -// +build !windows - -package lightwave - -import "errors" - -func (client *OIDCClient) GetTokensFromWindowsLogInContext() (tokens *OIDCTokenResponse, err error) { - return nil, errors.New("Not supported on this OS") -} diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/networks.go b/vendor/github.com/vmware/photon-controller-go-sdk/photon/networks.go deleted file mode 100644 index 35fc30f8315..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/networks.go +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (c) 2016 VMware, Inc. All Rights Reserved. -// -// This product is licensed to you under the Apache License, Version 2.0 (the "License"). -// You may not use this product except in compliance with the License. -// -// This product may include a number of subcomponents with separate copyright notices and -// license terms. Your use of these subcomponents is subject to the terms and conditions -// of the subcomponent's license, as noted in the LICENSE file. - -package photon - -import ( - "bytes" - "encoding/json" -) - -// Contains functionality for networks API. -type NetworksAPI struct { - client *Client -} - -// Options used for GetAll API -type NetworkGetOptions struct { - Name string `urlParam:"name"` -} - -var networkUrl string = rootUrl + "/subnets" - -// Creates a network. -func (api *NetworksAPI) Create(networkSpec *NetworkCreateSpec) (task *Task, err error) { - body, err := json.Marshal(networkSpec) - if err != nil { - return - } - res, err := api.client.restClient.Post( - api.client.Endpoint+networkUrl, - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Deletes a network with specified ID. -func (api *NetworksAPI) Delete(id string) (task *Task, err error) { - res, err := api.client.restClient.Delete(api.client.Endpoint+networkUrl+"/"+id, api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Gets a network with the specified ID. -func (api *NetworksAPI) Get(id string) (network *Network, err error) { - res, err := api.client.restClient.Get(api.client.Endpoint+networkUrl+"/"+id, api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - res, err = getError(res) - if err != nil { - return - } - var result Network - err = json.NewDecoder(res.Body).Decode(&result) - return &result, nil -} - -// Returns all networks -func (api *NetworksAPI) GetAll(options *NetworkGetOptions) (result *Networks, err error) { - uri := api.client.Endpoint + networkUrl - if options != nil { - uri += getQueryString(options) - } - res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions) - - result = &Networks{} - err = json.Unmarshal(res, result) - return -} - -// Sets default network. -func (api *NetworksAPI) SetDefault(id string) (task *Task, err error) { - res, err := api.client.restClient.Post( - api.client.Endpoint+networkUrl+"/"+id+"/set_default", - "application/json", - bytes.NewReader([]byte("")), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/projects.go b/vendor/github.com/vmware/photon-controller-go-sdk/photon/projects.go deleted file mode 100644 index 112adce0059..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/projects.go +++ /dev/null @@ -1,208 +0,0 @@ -// Copyright (c) 2016 VMware, Inc. All Rights Reserved. -// -// This product is licensed to you under the Apache License, Version 2.0 (the "License"). -// You may not use this product except in compliance with the License. -// -// This product may include a number of subcomponents with separate copyright notices and -// license terms. Your use of these subcomponents is subject to the terms and conditions -// of the subcomponent's license, as noted in the LICENSE file. - -package photon - -import ( - "bytes" - "encoding/json" -) - -// Contains functionality for projects API. -type ProjectsAPI struct { - client *Client -} - -// Options for GetDisks API. -type DiskGetOptions struct { - Name string `urlParam:"name"` -} - -// Options for GetDisks API. -type VmGetOptions struct { - Name string `urlParam:"name"` -} - -var projectUrl string = rootUrl + "/projects/" - -// Deletes the project with specified ID. Any VMs, disks, etc., owned by the project must be deleted first. -func (api *ProjectsAPI) Delete(projectID string) (task *Task, err error) { - res, err := api.client.restClient.Delete(api.client.Endpoint+projectUrl+projectID, api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Creates a disk on the specified project. -func (api *ProjectsAPI) CreateDisk(projectID string, spec *DiskCreateSpec) (task *Task, err error) { - body, err := json.Marshal(spec) - if err != nil { - return - } - res, err := api.client.restClient.Post( - api.client.Endpoint+projectUrl+projectID+"/disks", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Gets disks for project with the specified ID, using options to filter the results. -// If options is nil, no filtering will occur. -func (api *ProjectsAPI) GetDisks(projectID string, options *DiskGetOptions) (result *DiskList, err error) { - uri := api.client.Endpoint + projectUrl + projectID + "/disks" - if options != nil { - uri += getQueryString(options) - } - res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions) - if err != nil { - return - } - - result = &DiskList{} - err = json.Unmarshal(res, result) - return -} - -// Creates a VM on the specified project. -func (api *ProjectsAPI) CreateVM(projectID string, spec *VmCreateSpec) (task *Task, err error) { - body, err := json.Marshal(spec) - if err != nil { - return - } - res, err := api.client.restClient.Post( - api.client.Endpoint+projectUrl+projectID+"/vms", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Gets all tasks with the specified project ID, using options to filter the results. -// If options is nil, no filtering will occur. -func (api *ProjectsAPI) GetTasks(id string, options *TaskGetOptions) (result *TaskList, err error) { - uri := api.client.Endpoint + projectUrl + id + "/tasks" - if options != nil { - uri += getQueryString(options) - } - res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions) - if err != nil { - return - } - - result = &TaskList{} - err = json.Unmarshal(res, result) - return -} - -// Gets vms for project with the specified ID, using options to filter the results. -// If options is nil, no filtering will occur. -func (api *ProjectsAPI) GetVMs(projectID string, options *VmGetOptions) (result *VMs, err error) { - uri := api.client.Endpoint + projectUrl + projectID + "/vms" - if options != nil { - uri += getQueryString(options) - } - res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions) - if err != nil { - return - } - - result = &VMs{} - err = json.Unmarshal(res, result) - return -} - -// Creates a service on the specified project. -func (api *ProjectsAPI) CreateService(projectID string, spec *ServiceCreateSpec) (task *Task, err error) { - body, err := json.Marshal(spec) - if err != nil { - return - } - res, err := api.client.restClient.Post( - api.client.Endpoint+projectUrl+projectID+"/services", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Gets services for project with the specified ID -func (api *ProjectsAPI) GetServices(projectID string) (result *Services, err error) { - uri := api.client.Endpoint + projectUrl + projectID + "/services" - res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions) - if err != nil { - return - } - - result = &Services{} - err = json.Unmarshal(res, result) - return -} - -// Gets the project with a specified ID. -func (api *ProjectsAPI) Get(id string) (project *ProjectCompact, err error) { - res, err := api.client.restClient.Get(api.getEntityUrl(id), api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - res, err = getError(res) - if err != nil { - return - } - project = &ProjectCompact{} - err = json.NewDecoder(res.Body).Decode(project) - return -} - -// Set security groups for this project, overwriting any existing ones. -func (api *ProjectsAPI) SetSecurityGroups(projectID string, securityGroups *SecurityGroupsSpec) (*Task, error) { - return setSecurityGroups(api.client, api.getEntityUrl(projectID), securityGroups) -} - -func (api *ProjectsAPI) getEntityUrl(id string) string { - return api.client.Endpoint + projectUrl + id -} - -// Creates a router on the specified project. -func (api *ProjectsAPI) CreateRouter(projectID string, spec *RouterCreateSpec) (task *Task, err error) { - body, err := json.Marshal(spec) - if err != nil { - return - } - res, err := api.client.restClient.Post( - api.client.Endpoint+projectUrl+projectID+"/routers", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/resourcetickets.go b/vendor/github.com/vmware/photon-controller-go-sdk/photon/resourcetickets.go deleted file mode 100644 index bfa83063341..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/resourcetickets.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) 2016 VMware, Inc. All Rights Reserved. -// -// This product is licensed to you under the Apache License, Version 2.0 (the "License"). -// You may not use this product except in compliance with the License. -// -// This product may include a number of subcomponents with separate copyright notices and -// license terms. Your use of these subcomponents is subject to the terms and conditions -// of the subcomponent's license, as noted in the LICENSE file. - -package photon - -import ( - "encoding/json" -) - -// Contains functionality for hosts API. -type ResourceTicketsAPI struct { - client *Client -} - -var resourceTicketUrl string = rootUrl + "/resource-tickets/" - -// Gets all tasks with the specified resource ticket ID, using options to filter the results. -// If options is nil, no filtering will occur. -func (api *ResourceTicketsAPI) GetTasks(id string, options *TaskGetOptions) (result *TaskList, err error) { - uri := api.client.Endpoint + resourceTicketUrl + id + "/tasks" - if options != nil { - uri += getQueryString(options) - } - res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions) - if err != nil { - return - } - - result = &TaskList{} - err = json.Unmarshal(res, result) - return -} - -// Gets the resource ticket with a specified ID. -func (api *ResourceTicketsAPI) Get(id string) (resourceTicket *ResourceTicket, err error) { - res, err := api.client.restClient.Get(api.client.Endpoint+resourceTicketUrl+"/"+id, - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - res, err = getError(res) - if err != nil { - return - } - resourceTicket = &ResourceTicket{} - err = json.NewDecoder(res.Body).Decode(resourceTicket) - return -} diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/restclient.go b/vendor/github.com/vmware/photon-controller-go-sdk/photon/restclient.go deleted file mode 100644 index 1f521b3df62..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/restclient.go +++ /dev/null @@ -1,326 +0,0 @@ -// Copyright (c) 2016 VMware, Inc. All Rights Reserved. -// -// This product is licensed to you under the Apache License, Version 2.0 (the "License"). -// You may not use this product except in compliance with the License. -// -// This product may include a number of subcomponents with separate copyright notices and -// license terms. Your use of these subcomponents is subject to the terms and conditions -// of the subcomponent's license, as noted in the LICENSE file. - -package photon - -import ( - "bytes" - "crypto/rand" - "encoding/json" - "fmt" - "io" - "io/ioutil" - "log" - "net/http" - "os" - "path/filepath" - "strings" -) - -type restClient struct { - httpClient *http.Client - logger *log.Logger - Auth *AuthAPI - UpdateAccessTokenCallback TokenCallback -} - -type request struct { - Method string - URL string - ContentType string - Body io.Reader - Tokens *TokenOptions -} - -type page struct { - Items []interface{} `json:"items"` - NextPageLink string `json:"nextPageLink"` - PreviousPageLink string `json:"previousPageLink"` -} - -type documentList struct { - Items []interface{} -} - -type bodyRewinder func() io.Reader - -const appJson string = "application/json" - -// Root URL specifies the API version. -const rootUrl string = "/v1" - -// From https://golang.org/src/mime/multipart/writer.go -var quoteEscaper = strings.NewReplacer("\\", "\\\\", `"`, "\\\"") - -func (client *restClient) AppendSlice(origSlice []interface{}, dataToAppend []interface{}) []interface{} { - origLen := len(origSlice) - newLen := origLen + len(dataToAppend) - - if newLen > cap(origSlice) { - newSlice := make([]interface{}, (newLen+1)*2) - copy(newSlice, origSlice) - origSlice = newSlice - } - - origSlice = origSlice[0:newLen] - copy(origSlice[origLen:newLen], dataToAppend) - - return origSlice -} - -func (client *restClient) Get(url string, tokens *TokenOptions) (res *http.Response, err error) { - req := request{"GET", url, "", nil, tokens} - res, err = client.SendRequest(&req, nil) - return -} - -func (client *restClient) GetList(endpoint string, url string, tokens *TokenOptions) (result []byte, err error) { - req := request{"GET", url, "", nil, tokens} - res, err := client.SendRequest(&req, nil) - if err != nil { - return - } - res, err = getError(res) - if err != nil { - return - } - - decoder := json.NewDecoder(res.Body) - decoder.UseNumber() - - page := &page{} - err = decoder.Decode(page) - if err != nil { - return - } - - documentList := &documentList{} - documentList.Items = client.AppendSlice(documentList.Items, page.Items) - - for page.NextPageLink != "" { - req = request{"GET", endpoint + page.NextPageLink, "", nil, tokens} - res, err = client.SendRequest(&req, nil) - if err != nil { - return - } - res, err = getError(res) - if err != nil { - return - } - - decoder = json.NewDecoder(res.Body) - decoder.UseNumber() - - page.NextPageLink = "" - page.PreviousPageLink = "" - - err = decoder.Decode(page) - if err != nil { - return - } - - documentList.Items = client.AppendSlice(documentList.Items, page.Items) - } - - result, err = json.Marshal(documentList) - - return -} - -func (client *restClient) Post(url string, contentType string, body io.ReadSeeker, tokens *TokenOptions) (res *http.Response, err error) { - if contentType == "" { - contentType = appJson - } - - req := request{"POST", url, contentType, body, tokens} - rewinder := func() io.Reader { - body.Seek(0, 0) - return body - } - res, err = client.SendRequest(&req, rewinder) - return -} - -func (client *restClient) Patch(url string, contentType string, body io.ReadSeeker, tokens *TokenOptions) (res *http.Response, err error) { - if contentType == "" { - contentType = appJson - } - - req := request{"PATCH", url, contentType, body, tokens} - rewinder := func() io.Reader { - body.Seek(0, 0) - return body - } - res, err = client.SendRequest(&req, rewinder) - return -} - -func (client *restClient) Put(url string, contentType string, body io.ReadSeeker, tokens *TokenOptions) (res *http.Response, err error) { - if contentType == "" { - contentType = appJson - } - - req := request{"PUT", url, contentType, body, tokens} - rewinder := func() io.Reader { - body.Seek(0, 0) - return body - } - res, err = client.SendRequest(&req, rewinder) - return -} - -func (client *restClient) Delete(url string, tokens *TokenOptions) (res *http.Response, err error) { - req := request{"DELETE", url, "", nil, tokens} - res, err = client.SendRequest(&req, nil) - return -} - -func (client *restClient) SendRequest(req *request, bodyRewinder bodyRewinder) (res *http.Response, err error) { - res, err = client.sendRequestHelper(req) - // In most cases, we'll return immediately - // If the operation succeeded, but we got a 401 response and if we're using - // authentication, then we'll look into the body to see if the token expired - if err != nil { - return res, err - } - if res.StatusCode != 401 { - // It's not a 401, so the token didn't expire - return res, err - } - if req.Tokens == nil || req.Tokens.AccessToken == "" { - // We don't have a token, so we can't renew the token, no need to proceed - return res, err - } - - // We're going to look in the body to see if it failed because the token expired - // This means we need to read the body, but the functions that call us also - // expect to read the body. So we read the body, then create a new reader - // so they can read the body as normal. - body, err := ioutil.ReadAll(res.Body) - if err != nil { - return res, err - } - res.Body = ioutil.NopCloser(bytes.NewReader(body)) - - // Now see if we had an expired token or not - var apiError ApiError - err = json.Unmarshal(body, &apiError) - if err != nil { - return res, err - } - if apiError.Code != "ExpiredAuthToken" { - return res, nil - } - - // We were told that the access token expired, so try to renew it. - // Note that this looks recursive because GetTokensByRefreshToken() will - // call the /auth API, and therefore SendRequest(). However, it calls - // without a token, so we avoid having a loop - newTokens, err := client.Auth.GetTokensByRefreshToken(req.Tokens.RefreshToken) - if err != nil { - return res, err - } - req.Tokens.AccessToken = newTokens.AccessToken - if client.UpdateAccessTokenCallback != nil { - client.UpdateAccessTokenCallback(newTokens.AccessToken) - } - if req.Body != nil && bodyRewinder != nil { - req.Body = bodyRewinder() - } - res, err = client.sendRequestHelper(req) - return res, nil -} - -func (client *restClient) sendRequestHelper(req *request) (res *http.Response, err error) { - r, err := http.NewRequest(req.Method, req.URL, req.Body) - if err != nil { - client.logger.Printf("An error occured creating request %s on %s. Error: %s", req.Method, req.URL, err) - return - } - if req.ContentType != "" { - r.Header.Add("Content-Type", req.ContentType) - } - if req.Tokens != nil && req.Tokens.AccessToken != "" { - r.Header.Add("Authorization", "Bearer "+req.Tokens.AccessToken) - } - res, err = client.httpClient.Do(r) - if err != nil { - client.logger.Printf("An error occured when calling %s on %s. Error: %s", req.Method, req.URL, err) - return - } - - client.logger.Printf("[%s] %s - %s %s", res.Header.Get("request-id"), res.Status, req.Method, req.URL) - return -} - -func (client *restClient) MultipartUploadFile(url, filePath string, params map[string]string, tokens *TokenOptions) (res *http.Response, err error) { - file, err := os.Open(filePath) - if err != nil { - return - } - defer file.Close() - return client.MultipartUpload(url, file, filepath.Base(filePath), params, tokens) -} - -func (client *restClient) MultipartUpload(url string, reader io.ReadSeeker, filename string, params map[string]string, tokens *TokenOptions) (res *http.Response, err error) { - boundary := client.randomBoundary() - multiReader, contentType := client.createMultiReader(reader, filename, params, boundary) - rewinder := func() io.Reader { - reader.Seek(0, 0) - multiReader, _ := client.createMultiReader(reader, filename, params, boundary) - return multiReader - } - res, err = client.SendRequest(&request{"POST", url, contentType, multiReader, tokens}, rewinder) - - return -} - -func (client *restClient) createMultiReader(reader io.ReadSeeker, filename string, params map[string]string, boundary string) (io.Reader, string) { - // The mime/multipart package does not support streaming multipart data from disk, - // at least not without complicated, problematic goroutines that simultaneously read/write into a buffer. - // A much easier approach is to just construct the multipart request by hand, using io.MultiPart to - // concatenate the parts of the request together into a single io.Reader. - parts := []io.Reader{} - - // Create a part for each key, val pair in params - for k, v := range params { - parts = append(parts, client.createFieldPart(k, v, boundary)) - } - - start := fmt.Sprintf("\r\n--%s\r\n", boundary) - start += fmt.Sprintf("Content-Disposition: form-data; name=\"file\"; filename=\"%s\"\r\n", quoteEscaper.Replace(filename)) - start += fmt.Sprintf("Content-Type: application/octet-stream\r\n\r\n") - end := fmt.Sprintf("\r\n--%s--", boundary) - - // The request will consist of a reader to begin the request, a reader which points - // to the file data on disk, and a reader containing the closing boundary of the request. - parts = append(parts, strings.NewReader(start), reader, strings.NewReader(end)) - - contentType := fmt.Sprintf("multipart/form-data; boundary=%s", boundary) - - return io.MultiReader(parts...), contentType -} - -// From https://golang.org/src/mime/multipart/writer.go -func (client *restClient) randomBoundary() string { - var buf [30]byte - _, err := io.ReadFull(rand.Reader, buf[:]) - if err != nil { - panic(err) - } - return fmt.Sprintf("%x", buf[:]) -} - -// Creates a reader that encapsulates a single multipart form part -func (client *restClient) createFieldPart(fieldname, value, boundary string) io.Reader { - str := fmt.Sprintf("\r\n--%s\r\n", boundary) - str += fmt.Sprintf("Content-Disposition: form-data; name=\"%s\"\r\n\r\n", quoteEscaper.Replace(fieldname)) - str += value - return strings.NewReader(str) -} diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/routers.go b/vendor/github.com/vmware/photon-controller-go-sdk/photon/routers.go deleted file mode 100644 index 954c6b5e6e4..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/routers.go +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (c) 2017 VMware, Inc. All Rights Reserved. -// -// This product is licensed to you under the Apache License, Version 2.0 (the "License"). -// You may not use this product except in compliance with the License. -// -// This product may include a number of subcomponents with separate copyright notices and -// license terms. Your use of these subcomponents is subject to the terms and conditions -// of the subcomponent's license, as noted in the LICENSE file. - -package photon - -import ( - "bytes" - "encoding/json" -) - -// Contains functionality for routers API. -type RoutersAPI struct { - client *Client -} - -var routerUrl string = rootUrl + "/routers/" - -// Gets a router with the specified ID. -func (api *RoutersAPI) Get(id string) (router *Router, err error) { - res, err := api.client.restClient.Get(api.client.Endpoint+routerUrl+id, api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - res, err = getError(res) - if err != nil { - return - } - var result Router - err = json.NewDecoder(res.Body).Decode(&result) - return &result, nil -} - -// Updates router's attributes. -func (api *RoutersAPI) UpdateRouter(id string, routerSpec *RouterUpdateSpec) (task *Task, err error) { - body, err := json.Marshal(routerSpec) - if err != nil { - return - } - - res, err := api.client.restClient.Put( - api.client.Endpoint+routerUrl+id, - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Deletes a router with specified ID. -func (api *RoutersAPI) Delete(routerID string) (task *Task, err error) { - res, err := api.client.restClient.Delete(api.client.Endpoint+routerUrl+routerID, api.client.options.TokenOptions) - if err != nil { - return - } - - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Creates a subnet on the specified router. -func (api *RoutersAPI) CreateSubnet(routerID string, spec *SubnetCreateSpec) (task *Task, err error) { - body, err := json.Marshal(spec) - if err != nil { - return - } - res, err := api.client.restClient.Post( - api.client.Endpoint+routerUrl+routerID+"/subnets", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/services.go b/vendor/github.com/vmware/photon-controller-go-sdk/photon/services.go deleted file mode 100644 index bd191e2cbc2..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/services.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) 2016 VMware, Inc. All Rights Reserved. -// -// This product is licensed to you under the Apache License, Version 2.0 (the "License"). -// You may not use this product except in compliance with the License. -// -// This product may include a number of subcomponents with separate copyright notices and -// license terms. Your use of these subcomponents is subject to the terms and conditions -// of the subcomponent's license, as noted in the LICENSE file. - -package photon - -import ( - "bytes" - "encoding/json" -) - -// Contains functionality for services API. -type ServicesAPI struct { - client *Client -} - -var serviceUrl = rootUrl + "/services/" - -// Extended Properties -const ( - ExtendedPropertyDNS = "dns" - ExtendedPropertyGateway = "gateway" - ExtendedPropertyNetMask = "netmask" - ExtendedPropertyLoadBalancerIP = "load_balancer_ip" - ExtendedPropertyNumberOfMasters = "number_of_masters" - ExtendedPropertyMasterIPs = "master_ips" - ExtendedPropertyMasterIP = "master_ip" - ExtendedPropertyMasterIP2 = "master_ip2" - ExtendedPropertyContainerNetwork = "container_network" - ExtendedPropertyZookeeperIP1 = "zookeeper_ip1" - ExtendedPropertyZookeeperIP2 = "zookeeper_ip2" - ExtendedPropertyZookeeperIP3 = "zookeeper_ip3" - ExtendedPropertyNumberOfETCDs = "number_of_etcds" - ExtendedPropertyETCDIP1 = "etcd_ip1" - ExtendedPropertyETCDIP2 = "etcd_ip2" - ExtendedPropertyETCDIP3 = "etcd_ip3" - ExtendedPropertySSHKey = "ssh_key" - ExtendedPropertyRegistryCACert = "registry_ca_cert" - ExtendedPropertyAdminPassword = "admin_password" -) - -// Deletes a service with specified ID. -func (api *ServicesAPI) Delete(id string) (task *Task, err error) { - res, err := api.client.restClient.Delete(api.client.Endpoint+serviceUrl+id, api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Gets a service with the specified ID. -func (api *ServicesAPI) Get(id string) (service *Service, err error) { - res, err := api.client.restClient.Get(api.client.Endpoint+serviceUrl+id, api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - res, err = getError(res) - if err != nil { - return - } - var result Service - err = json.NewDecoder(res.Body).Decode(&result) - return &result, nil -} - -// Gets vms for service with the specified ID. -func (api *ServicesAPI) GetVMs(id string) (result *VMs, err error) { - uri := api.client.Endpoint + serviceUrl + id + "/vms" - res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions) - if err != nil { - return - } - - result = &VMs{} - err = json.Unmarshal(res, result) - return -} - -// Resize a service to specified count. -func (api *ServicesAPI) Resize(id string, resize *ServiceResizeOperation) (task *Task, err error) { - body, err := json.Marshal(resize) - if err != nil { - return - } - res, err := api.client.restClient.Post( - api.client.Endpoint+serviceUrl+id+"/resize", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Start a background process to recreate failed VMs in a service with the specified ID. -func (api *ServicesAPI) TriggerMaintenance(id string) (task *Task, err error) { - body := []byte{} - res, err := api.client.restClient.Post( - api.client.Endpoint+serviceUrl+id+"/trigger_maintenance", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Change a service version to the specified image by destroying and recreating the VMs. -func (api *ServicesAPI) ChangeVersion(id string, changeVersion *ServiceChangeVersionOperation) (task *Task, err error) { - body, err := json.Marshal(changeVersion) - if err != nil { - return - } - res, err := api.client.restClient.Post( - api.client.Endpoint+serviceUrl+id+"/change_version", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/status.go b/vendor/github.com/vmware/photon-controller-go-sdk/photon/status.go deleted file mode 100644 index dd213dc3b01..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/status.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 2016 VMware, Inc. All Rights Reserved. -// -// This product is licensed to you under the Apache License, Version 2.0 (the "License"). -// You may not use this product except in compliance with the License. -// -// This product may include a number of subcomponents with separate copyright notices and -// license terms. Your use of these subcomponents is subject to the terms and conditions -// of the subcomponent's license, as noted in the LICENSE file. - -package photon - -import ( - "encoding/json" -) - -// Contains functionality for status API. -type StatusAPI struct { - client *Client -} - -var statusUrl string = rootUrl + "/status" - -// Returns the status of an photon endpoint. -func (api *StatusAPI) Get() (status *Status, err error) { - res, err := api.client.restClient.Get(api.client.Endpoint+statusUrl, api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - res, err = getError(res) - if err != nil { - return - } - status = &Status{} - err = json.NewDecoder(res.Body).Decode(status) - return -} diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/subnets.go b/vendor/github.com/vmware/photon-controller-go-sdk/photon/subnets.go deleted file mode 100644 index ca0f293468d..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/subnets.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) 2017 VMware, Inc. All Rights Reserved. -// -// This product is licensed to you under the Apache License, Version 2.0 (the "License"). -// You may not use this product except in compliance with the License. -// -// This product may include a number of subcomponents with separate copyright notices and -// license terms. Your use of these subcomponents is subject to the terms and conditions -// of the subcomponent's license, as noted in the LICENSE file. - -package photon - -import ( - "bytes" - "encoding/json" -) - -// Contains functionality for subnets API. -type SubnetsAPI struct { - client *Client -} - -var subnetUrl string = "/temp-subnets/" - -// Deletes a subnet with the specified ID. -func (api *SubnetsAPI) Delete(id string) (task *Task, err error) { - res, err := api.client.restClient.Delete(api.client.Endpoint+subnetUrl+id, api.client.options.TokenOptions) - if err != nil { - return - } - - defer res.Body.Close() - - task, err = getTask(getError(res)) - return -} - -// Gets a subnet with the specified ID. -func (api *SubnetsAPI) Get(id string) (subnet *Subnet, err error) { - res, err := api.client.restClient.Get(api.client.Endpoint+subnetUrl+id, api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - res, err = getError(res) - if err != nil { - return - } - var result Subnet - err = json.NewDecoder(res.Body).Decode(&result) - return &result, nil -} - -// Updates subnet's attributes. -func (api *SubnetsAPI) Update(id string, subnetSpec *SubnetUpdateSpec) (task *Task, err error) { - body, err := json.Marshal(subnetSpec) - if err != nil { - return - } - - res, err := api.client.restClient.Put( - api.client.Endpoint+subnetUrl+id, - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/tasks.go b/vendor/github.com/vmware/photon-controller-go-sdk/photon/tasks.go deleted file mode 100644 index 3ebe9d8b2e3..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/tasks.go +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (c) 2016 VMware, Inc. All Rights Reserved. -// -// This product is licensed to you under the Apache License, Version 2.0 (the "License"). -// You may not use this product except in compliance with the License. -// -// This product may include a number of subcomponents with separate copyright notices and -// license terms. Your use of these subcomponents is subject to the terms and conditions -// of the subcomponent's license, as noted in the LICENSE file. - -package photon - -import ( - "encoding/json" - "time" -) - -// Contains functionality for tasks API. -type TasksAPI struct { - client *Client -} - -var taskUrl string = rootUrl + "/tasks" - -// Gets a task by ID. -func (api *TasksAPI) Get(id string) (task *Task, err error) { - res, err := api.client.restClient.Get(api.client.Endpoint+taskUrl+"/"+id, api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - result, err := getTask(getError(res)) - return result, err -} - -// Gets all tasks, using options to filter the results. -// If options is nil, no filtering will occur. -func (api *TasksAPI) GetAll(options *TaskGetOptions) (result *TaskList, err error) { - uri := api.client.Endpoint + taskUrl - if options != nil { - uri += getQueryString(options) - } - res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions) - if err != nil { - return - } - - result = &TaskList{} - err = json.Unmarshal(res, result) - - return -} - -// Waits for a task to complete by polling the tasks API until a task returns with -// the state COMPLETED or ERROR. Will wait no longer than the duration specified by timeout. -func (api *TasksAPI) WaitTimeout(id string, timeout time.Duration) (task *Task, err error) { - start := time.Now() - numErrors := 0 - maxErrors := api.client.options.TaskRetryCount - - for time.Since(start) < timeout { - task, err = api.Get(id) - if err != nil { - switch err.(type) { - // If an ApiError comes back, something is wrong, return the error to the caller - case ApiError: - return - // For other errors, retry before giving up - default: - numErrors++ - if numErrors > maxErrors { - return - } - } - } else { - // Reset the error count any time a successful call is made - numErrors = 0 - if task.State == "COMPLETED" { - return - } - if task.State == "ERROR" { - err = TaskError{task.ID, getFailedStep(task)} - return - } - } - time.Sleep(api.client.options.TaskPollDelay) - } - err = TaskTimeoutError{id} - return -} - -// Waits for a task to complete by polling the tasks API until a task returns with -// the state COMPLETED or ERROR. -func (api *TasksAPI) Wait(id string) (task *Task, err error) { - return api.WaitTimeout(id, api.client.options.TaskPollTimeout) -} - -// Gets the failed step in the task to get error details for failed task. -func getFailedStep(task *Task) (step Step) { - var errorStep Step - for _, s := range task.Steps { - if s.State == "ERROR" { - errorStep = s - break - } - } - - return errorStep -} diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/tenants.go b/vendor/github.com/vmware/photon-controller-go-sdk/photon/tenants.go deleted file mode 100644 index c6b98eb4c2b..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/tenants.go +++ /dev/null @@ -1,213 +0,0 @@ -// Copyright (c) 2016 VMware, Inc. All Rights Reserved. -// -// This product is licensed to you under the Apache License, Version 2.0 (the "License"). -// You may not use this product except in compliance with the License. -// -// This product may include a number of subcomponents with separate copyright notices and -// license terms. Your use of these subcomponents is subject to the terms and conditions -// of the subcomponent's license, as noted in the LICENSE file. - -package photon - -import ( - "bytes" - "encoding/json" - "fmt" -) - -// Contains functionality for tenants API. -type TenantsAPI struct { - client *Client -} - -// Options for GetResourceTickets API. -type ResourceTicketGetOptions struct { - Name string `urlParam:"name"` -} - -// Options for GetProjects API. -type ProjectGetOptions struct { - Name string `urlParam:"name"` -} - -var tenantUrl string = rootUrl + "/tenants" - -// Returns all tenants on an photon instance. -func (api *TenantsAPI) GetAll() (result *Tenants, err error) { - uri := api.client.Endpoint + tenantUrl - res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions) - if err != nil { - return - } - - result = &Tenants{} - err = json.Unmarshal(res, result) - return -} - -// Creates a tenant. -func (api *TenantsAPI) Create(tenantSpec *TenantCreateSpec) (task *Task, err error) { - body, err := json.Marshal(tenantSpec) - if err != nil { - return - } - res, err := api.client.restClient.Post( - api.client.Endpoint+tenantUrl, - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Deletes the tenant with specified ID. Any projects, VMs, disks, etc., owned by the tenant must be deleted first. -func (api *TenantsAPI) Delete(id string) (task *Task, err error) { - res, err := api.client.restClient.Delete(api.client.Endpoint+tenantUrl+"/"+id, api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Creates a resource ticket on the specified tenant. -func (api *TenantsAPI) CreateResourceTicket(tenantId string, spec *ResourceTicketCreateSpec) (task *Task, err error) { - body, err := json.Marshal(spec) - if err != nil { - return - } - res, err := api.client.restClient.Post( - api.client.Endpoint+tenantUrl+"/"+tenantId+"/resource-tickets", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Gets resource tickets for tenant with the specified ID, using options to filter the results. -// If options is nil, no filtering will occur. -func (api *TenantsAPI) GetResourceTickets(tenantId string, options *ResourceTicketGetOptions) (tickets *ResourceList, err error) { - uri := api.client.Endpoint + tenantUrl + "/" + tenantId + "/resource-tickets" - if options != nil { - uri += getQueryString(options) - } - res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions) - if err != nil { - return - } - - tickets = &ResourceList{} - err = json.Unmarshal(res, tickets) - return -} - -// Creates a project on the specified tenant. -func (api *TenantsAPI) CreateProject(tenantId string, spec *ProjectCreateSpec) (task *Task, err error) { - body, err := json.Marshal(spec) - if err != nil { - return - } - res, err := api.client.restClient.Post( - api.client.Endpoint+tenantUrl+"/"+tenantId+"/projects", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Gets the projects for tenant with the specified ID, using options to filter the results. -// If options is nil, no filtering will occur. -func (api *TenantsAPI) GetProjects(tenantId string, options *ProjectGetOptions) (result *ProjectList, err error) { - uri := api.client.Endpoint + tenantUrl + "/" + tenantId + "/projects" - if options != nil { - uri += getQueryString(options) - } - res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions) - if err != nil { - return - } - - result = &(ProjectList{}) - err = json.Unmarshal(res, result) - return -} - -// Gets all tasks with the specified tenant ID, using options to filter the results. -// If options is nil, no filtering will occur. -func (api *TenantsAPI) GetTasks(id string, options *TaskGetOptions) (result *TaskList, err error) { - uri := api.client.Endpoint + tenantUrl + "/" + id + "/tasks" - if options != nil { - uri += getQueryString(options) - } - res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions) - if err != nil { - return - } - - result = &TaskList{} - err = json.Unmarshal(res, result) - return -} - -// Gets a tenant with the specified ID or name -func (api *TenantsAPI) Get(identity string) (tenant *Tenant, err error) { - res, err := api.client.restClient.Get(api.getEntityUrl(identity), api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - res, err = getError(res) - tenant = &Tenant{} - if res != nil { - err = json.NewDecoder(res.Body).Decode(tenant) - // ID corresponds to the tenant ID found, return tenant - if err == nil { - return - } - } - // Find by Name - uri := api.client.Endpoint + tenantUrl + "?name=" + identity - res2, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions) - - if err != nil { - return - } - - tenants := &Tenants{} - err = json.Unmarshal(res2, tenants) - if err != nil { - return - } - - if len(tenants.Items) < 1 { - err = fmt.Errorf("Cannot find a tenant with id or name match %s", identity) - return - } - - tenant = &(tenants.Items[0]) - return -} - -// Set security groups for this tenant, overwriting any existing ones. -func (api *TenantsAPI) SetSecurityGroups(id string, securityGroups *SecurityGroupsSpec) (*Task, error) { - return setSecurityGroups(api.client, api.getEntityUrl(id), securityGroups) -} - -func (api *TenantsAPI) getEntityUrl(id string) (url string) { - return api.client.Endpoint + tenantUrl + "/" + id -} diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/util.go b/vendor/github.com/vmware/photon-controller-go-sdk/photon/util.go deleted file mode 100644 index a2a44f93886..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/util.go +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) 2016 VMware, Inc. All Rights Reserved. -// -// This product is licensed to you under the Apache License, Version 2.0 (the "License"). -// You may not use this product except in compliance with the License. -// -// This product may include a number of subcomponents with separate copyright notices and -// license terms. Your use of these subcomponents is subject to the terms and conditions -// of the subcomponent's license, as noted in the LICENSE file. - -package photon - -import ( - "bytes" - "encoding/json" - "fmt" - "io/ioutil" - "net/http" - "net/url" - "reflect" -) - -// Reads an error out of the HTTP response, or does nothing if -// no error occured. -func getError(res *http.Response) (*http.Response, error) { - // Do nothing if the response is a successful 2xx - if res.StatusCode/100 == 2 { - return res, nil - } - var apiError ApiError - // ReadAll is usually a bad practice, but here we need to read the response all - // at once because we may attempt to use the data twice. It's preferable to use - // methods that take io.Reader, e.g. json.NewDecoder - body, err := ioutil.ReadAll(res.Body) - if err != nil { - return nil, err - } - err = json.Unmarshal(body, &apiError) - if err != nil { - // If deserializing into ApiError fails, return a generic HttpError instead - return nil, HttpError{res.StatusCode, string(body[:])} - } - apiError.HttpStatusCode = res.StatusCode - return nil, apiError -} - -// Reads a task object out of the HTTP response. Takes an error argument -// so that GetTask can easily wrap GetError. This function will do nothing -// if e is not nil. -// e.g. res, err := getTask(getError(someApi.Get())) -func getTask(res *http.Response, e error) (*Task, error) { - if e != nil { - return nil, e - } - var task Task - err := json.NewDecoder(res.Body).Decode(&task) - if err != nil { - return nil, err - } - if task.State == "ERROR" { - // Critical: return task as well, so that it can be examined - // for error details. - return &task, TaskError{task.ID, getFailedStep(&task)} - } - return &task, nil -} - -// Converts an options struct into a query string. -// E.g. type Foo struct {A int; B int} might return "?a=5&b=10". -// Will return an empty string if no options are set. -func getQueryString(options interface{}) string { - buffer := bytes.Buffer{} - buffer.WriteString("?") - strct := reflect.ValueOf(options).Elem() - typ := strct.Type() - for i := 0; i < strct.NumField(); i++ { - field := strct.Field(i) - value := fmt.Sprint(field.Interface()) - if value != "" { - buffer.WriteString(typ.Field(i).Tag.Get("urlParam") + "=" + url.QueryEscape(value)) - if i < strct.NumField()-1 { - buffer.WriteString("&") - } - } - } - uri := buffer.String() - if uri == "?" { - return "" - } - return uri -} - -// Sets security groups for a given entity (deployment/tenant/project) -func setSecurityGroups(client *Client, entityUrl string, securityGroups *SecurityGroupsSpec) (task *Task, err error) { - body, err := json.Marshal(securityGroups) - if err != nil { - return - } - url := entityUrl + "/set_security_groups" - res, err := client.restClient.Post( - url, - "application/json", - bytes.NewReader(body), - client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/virtualnetworks.go b/vendor/github.com/vmware/photon-controller-go-sdk/photon/virtualnetworks.go deleted file mode 100644 index e1b9b9a2e82..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/virtualnetworks.go +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (c) 2016 VMware, Inc. All Rights Reserved. -// -// This product is licensed to you under the Apache License, Version 2.0 (the "License"). -// You may not use this product except in compliance with the License. -// -// This product may include a number of subcomponents with separate copyright notices and -// license terms. Your use of these subcomponents is subject to the terms and conditions -// of the subcomponent's license, as noted in the LICENSE file. - -package photon - -import ( - "bytes" - "encoding/json" -) - -// Contains pointer to api client. -type VirtualSubnetsAPI struct { - client *Client -} - -// Options used for GetAll API -type VirtualSubnetGetOptions struct { - Name string `urlParam:"name"` -} - -var subnetsUrl = rootUrl + "/subnets" -var projectsUrl = rootUrl + "/projects" - -// Create a virtual network -func (api *VirtualSubnetsAPI) Create(projectId string, - virtualNetworkSpec *VirtualSubnetCreateSpec) (task *Task, err error) { - - body, err := json.Marshal(virtualNetworkSpec) - if err != nil { - return - } - - res, err := api.client.restClient.Post( - api.client.Endpoint+projectsUrl+"/"+projectId+"/subnets", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - - defer res.Body.Close() - - task, err = getTask(getError(res)) - return -} - -// Delete a virtual network with the specified ID. -func (api *VirtualSubnetsAPI) Delete(id string) (task *Task, err error) { - res, err := api.client.restClient.Delete(api.client.Endpoint+subnetsUrl+"/"+id, - api.client.options.TokenOptions) - if err != nil { - return - } - - defer res.Body.Close() - - task, err = getTask(getError(res)) - return -} - -// Get the virtual subnet with the specified id -func (api *VirtualSubnetsAPI) Get(id string) (subnet *VirtualSubnet, err error) { - res, err := api.client.restClient.Get(api.client.Endpoint+subnetsUrl+"/"+id, - api.client.options.TokenOptions) - if err != nil { - return - } - - defer res.Body.Close() - - res, err = getError(res) - if err != nil { - return - } - - subnet = new(VirtualSubnet) - err = json.NewDecoder(res.Body).Decode(subnet) - return -} - -// Return all virtual networks -func (api *VirtualSubnetsAPI) GetAll(projectId string, - options *VirtualSubnetGetOptions) (subnets *VirtualSubnets, err error) { - - uri := api.client.Endpoint + projectsUrl + "/" + projectId + "/subnets" - if options != nil { - uri += getQueryString(options) - } - - res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions) - if err != nil { - return - } - - subnets = &VirtualSubnets{} - err = json.Unmarshal(res, subnets) - - return -} - -func (api *VirtualSubnetsAPI) SetDefault(id string) (task *Task, err error) { - res, err := api.client.restClient.Post( - api.client.Endpoint+subnetsUrl+"/"+id+"/set_default", - "application/json", - bytes.NewReader([]byte("")), - api.client.options.TokenOptions) - if err != nil { - return - } - - defer res.Body.Close() - - task, err = getTask(getError(res)) - return -} diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/vms.go b/vendor/github.com/vmware/photon-controller-go-sdk/photon/vms.go deleted file mode 100644 index 5f50d05ee24..00000000000 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/vms.go +++ /dev/null @@ -1,327 +0,0 @@ -// Copyright (c) 2016 VMware, Inc. All Rights Reserved. -// -// This product is licensed to you under the Apache License, Version 2.0 (the "License"). -// You may not use this product except in compliance with the License. -// -// This product may include a number of subcomponents with separate copyright notices and -// license terms. Your use of these subcomponents is subject to the terms and conditions -// of the subcomponent's license, as noted in the LICENSE file. - -package photon - -import ( - "bytes" - "encoding/json" - "io" -) - -// Contains functionality for VMs API. -type VmAPI struct { - client *Client -} - -var vmUrl string = rootUrl + "/vms/" - -func (api *VmAPI) Get(id string) (vm *VM, err error) { - res, err := api.client.restClient.Get(api.client.Endpoint+vmUrl+id, api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - res, err = getError(res) - if err != nil { - return - } - vm = &VM{} - err = json.NewDecoder(res.Body).Decode(vm) - return -} - -func (api *VmAPI) Delete(id string) (task *Task, err error) { - res, err := api.client.restClient.Delete(api.client.Endpoint+vmUrl+id, api.client.options.TokenOptions) - - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -func (api *VmAPI) AttachDisk(id string, op *VmDiskOperation) (task *Task, err error) { - body, err := json.Marshal(op) - if err != nil { - return - } - res, err := api.client.restClient.Post( - api.client.Endpoint+vmUrl+id+"/attach_disk", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -func (api *VmAPI) DetachDisk(id string, op *VmDiskOperation) (task *Task, err error) { - body, err := json.Marshal(op) - if err != nil { - return - } - res, err := api.client.restClient.Post( - api.client.Endpoint+vmUrl+id+"/detach_disk", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -func (api *VmAPI) AttachISO(id string, reader io.ReadSeeker, name string) (task *Task, err error) { - res, err := api.client.restClient.MultipartUpload( - api.client.Endpoint+vmUrl+id+"/attach_iso", reader, name, nil, api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - result, err := getTask(getError(res)) - return result, err -} - -func (api *VmAPI) DetachISO(id string) (task *Task, err error) { - body := []byte{} - if err != nil { - return - } - res, err := api.client.restClient.Post( - api.client.Endpoint+vmUrl+id+"/detach_iso", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -func (api *VmAPI) Start(id string) (task *Task, err error) { - body := []byte{} - if err != nil { - return - } - res, err := api.client.restClient.Post( - api.client.Endpoint+vmUrl+id+"/start", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -func (api *VmAPI) Stop(id string) (task *Task, err error) { - body := []byte{} - if err != nil { - return - } - res, err := api.client.restClient.Post( - api.client.Endpoint+vmUrl+id+"/stop", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -func (api *VmAPI) Restart(id string) (task *Task, err error) { - body := []byte{} - if err != nil { - return - } - res, err := api.client.restClient.Post( - api.client.Endpoint+vmUrl+id+"/restart", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -func (api *VmAPI) Resume(id string) (task *Task, err error) { - body := []byte{} - if err != nil { - return - } - res, err := api.client.restClient.Post( - api.client.Endpoint+vmUrl+id+"/resume", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -func (api *VmAPI) Suspend(id string) (task *Task, err error) { - body := []byte{} - if err != nil { - return - } - res, err := api.client.restClient.Post( - api.client.Endpoint+vmUrl+id+"/suspend", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -func (api *VmAPI) SetMetadata(id string, metadata *VmMetadata) (task *Task, err error) { - body, err := json.Marshal(metadata) - if err != nil { - return - } - res, err := api.client.restClient.Post( - api.client.Endpoint+vmUrl+id+"/set_metadata", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -// Gets all tasks with the specified vm ID, using options to filter the results. -// If options is nil, no filtering will occur. -func (api *VmAPI) GetTasks(id string, options *TaskGetOptions) (result *TaskList, err error) { - uri := api.client.Endpoint + vmUrl + id + "/tasks" - if options != nil { - uri += getQueryString(options) - } - res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions) - if err != nil { - return - } - - result = &TaskList{} - err = json.Unmarshal(res, result) - return -} - -func (api *VmAPI) GetNetworks(id string) (task *Task, err error) { - res, err := api.client.restClient.Get(api.client.Endpoint+vmUrl+id+"/subnets", api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -func (api *VmAPI) AcquireFloatingIp(id string, spec *VmFloatingIpSpec) (task *Task, err error) { - body, err := json.Marshal(spec) - if err != nil { - return - } - - res, err := api.client.restClient.Post( - api.client.Endpoint+vmUrl+id+"/acquire_floating_ip", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -func (api *VmAPI) ReleaseFloatingIp(id string) (task *Task, err error) { - - res, err := api.client.restClient.Delete( - api.client.Endpoint+vmUrl+id+"/release_floating_ip", - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -func (api *VmAPI) GetMKSTicket(id string) (task *Task, err error) { - res, err := api.client.restClient.Get(api.client.Endpoint+vmUrl+id+"/mks_ticket", api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -func (api *VmAPI) SetTag(id string, tag *VmTag) (task *Task, err error) { - body, err := json.Marshal(tag) - if err != nil { - return - } - res, err := api.client.restClient.Post( - api.client.Endpoint+vmUrl+id+"/tags", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} - -func (api *VmAPI) CreateImage(id string, options *ImageCreateSpec) (task *Task, err error) { - body, err := json.Marshal(options) - if err != nil { - return - } - res, err := api.client.restClient.Post( - api.client.Endpoint+vmUrl+id+"/create_image", - "application/json", - bytes.NewReader(body), - api.client.options.TokenOptions) - if err != nil { - return - } - defer res.Body.Close() - task, err = getTask(getError(res)) - return -} diff --git a/vendor/github.com/xanzy/go-cloudstack/LICENSE b/vendor/github.com/xanzy/go-cloudstack/LICENSE deleted file mode 100644 index 5c304d1a4a7..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ -Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/APIDiscoveryService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/APIDiscoveryService.go deleted file mode 100644 index 490d36d650e..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/APIDiscoveryService.go +++ /dev/null @@ -1,96 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "net/url" -) - -type ListApisParams struct { - p map[string]interface{} -} - -func (p *ListApisParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - return u -} - -func (p *ListApisParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -// You should always use this function to get a new ListApisParams instance, -// as then you are sure you have configured all required params -func (s *APIDiscoveryService) NewListApisParams() *ListApisParams { - p := &ListApisParams{} - p.p = make(map[string]interface{}) - return p -} - -// lists all available apis on the server, provided by the Api Discovery plugin -func (s *APIDiscoveryService) ListApis(p *ListApisParams) (*ListApisResponse, error) { - resp, err := s.cs.newRequest("listApis", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListApisResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListApisResponse struct { - Count int `json:"count"` - Apis []*Api `json:"api"` -} - -type Api struct { - Description string `json:"description,omitempty"` - Isasync bool `json:"isasync,omitempty"` - Name string `json:"name,omitempty"` - Params []struct { - Description string `json:"description,omitempty"` - Length int `json:"length,omitempty"` - Name string `json:"name,omitempty"` - Related string `json:"related,omitempty"` - Required bool `json:"required,omitempty"` - Since string `json:"since,omitempty"` - Type string `json:"type,omitempty"` - } `json:"params,omitempty"` - Related string `json:"related,omitempty"` - Response []struct { - Description string `json:"description,omitempty"` - Name string `json:"name,omitempty"` - Response []string `json:"response,omitempty"` - Type string `json:"type,omitempty"` - } `json:"response,omitempty"` - Since string `json:"since,omitempty"` - Type string `json:"type,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/AccountService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/AccountService.go deleted file mode 100644 index 28b50b66ad5..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/AccountService.go +++ /dev/null @@ -1,1903 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type CreateAccountParams struct { - p map[string]interface{} -} - -func (p *CreateAccountParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["accountdetails"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("accountdetails[%d].key", i), k) - u.Set(fmt.Sprintf("accountdetails[%d].value", i), vv) - i++ - } - } - if v, found := p.p["accountid"]; found { - u.Set("accountid", v.(string)) - } - if v, found := p.p["accounttype"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("accounttype", vv) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["email"]; found { - u.Set("email", v.(string)) - } - if v, found := p.p["firstname"]; found { - u.Set("firstname", v.(string)) - } - if v, found := p.p["lastname"]; found { - u.Set("lastname", v.(string)) - } - if v, found := p.p["networkdomain"]; found { - u.Set("networkdomain", v.(string)) - } - if v, found := p.p["password"]; found { - u.Set("password", v.(string)) - } - if v, found := p.p["timezone"]; found { - u.Set("timezone", v.(string)) - } - if v, found := p.p["userid"]; found { - u.Set("userid", v.(string)) - } - if v, found := p.p["username"]; found { - u.Set("username", v.(string)) - } - return u -} - -func (p *CreateAccountParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *CreateAccountParams) SetAccountdetails(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["accountdetails"] = v - return -} - -func (p *CreateAccountParams) SetAccountid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["accountid"] = v - return -} - -func (p *CreateAccountParams) SetAccounttype(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["accounttype"] = v - return -} - -func (p *CreateAccountParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *CreateAccountParams) SetEmail(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["email"] = v - return -} - -func (p *CreateAccountParams) SetFirstname(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["firstname"] = v - return -} - -func (p *CreateAccountParams) SetLastname(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["lastname"] = v - return -} - -func (p *CreateAccountParams) SetNetworkdomain(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkdomain"] = v - return -} - -func (p *CreateAccountParams) SetPassword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["password"] = v - return -} - -func (p *CreateAccountParams) SetTimezone(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["timezone"] = v - return -} - -func (p *CreateAccountParams) SetUserid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["userid"] = v - return -} - -func (p *CreateAccountParams) SetUsername(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["username"] = v - return -} - -// You should always use this function to get a new CreateAccountParams instance, -// as then you are sure you have configured all required params -func (s *AccountService) NewCreateAccountParams(accounttype int, email string, firstname string, lastname string, password string, username string) *CreateAccountParams { - p := &CreateAccountParams{} - p.p = make(map[string]interface{}) - p.p["accounttype"] = accounttype - p.p["email"] = email - p.p["firstname"] = firstname - p.p["lastname"] = lastname - p.p["password"] = password - p.p["username"] = username - return p -} - -// Creates an account -func (s *AccountService) CreateAccount(p *CreateAccountParams) (*CreateAccountResponse, error) { - resp, err := s.cs.newRequest("createAccount", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateAccountResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type CreateAccountResponse struct { - Accountdetails map[string]string `json:"accountdetails,omitempty"` - Accounttype int `json:"accounttype,omitempty"` - Cpuavailable string `json:"cpuavailable,omitempty"` - Cpulimit string `json:"cpulimit,omitempty"` - Cputotal int64 `json:"cputotal,omitempty"` - Defaultzoneid string `json:"defaultzoneid,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Groups []string `json:"groups,omitempty"` - Id string `json:"id,omitempty"` - Ipavailable string `json:"ipavailable,omitempty"` - Iplimit string `json:"iplimit,omitempty"` - Iptotal int64 `json:"iptotal,omitempty"` - Iscleanuprequired bool `json:"iscleanuprequired,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Memoryavailable string `json:"memoryavailable,omitempty"` - Memorylimit string `json:"memorylimit,omitempty"` - Memorytotal int64 `json:"memorytotal,omitempty"` - Name string `json:"name,omitempty"` - Networkavailable string `json:"networkavailable,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Networklimit string `json:"networklimit,omitempty"` - Networktotal int64 `json:"networktotal,omitempty"` - Primarystorageavailable string `json:"primarystorageavailable,omitempty"` - Primarystoragelimit string `json:"primarystoragelimit,omitempty"` - Primarystoragetotal int64 `json:"primarystoragetotal,omitempty"` - Projectavailable string `json:"projectavailable,omitempty"` - Projectlimit string `json:"projectlimit,omitempty"` - Projecttotal int64 `json:"projecttotal,omitempty"` - Receivedbytes int64 `json:"receivedbytes,omitempty"` - Secondarystorageavailable string `json:"secondarystorageavailable,omitempty"` - Secondarystoragelimit string `json:"secondarystoragelimit,omitempty"` - Secondarystoragetotal int64 `json:"secondarystoragetotal,omitempty"` - Sentbytes int64 `json:"sentbytes,omitempty"` - Snapshotavailable string `json:"snapshotavailable,omitempty"` - Snapshotlimit string `json:"snapshotlimit,omitempty"` - Snapshottotal int64 `json:"snapshottotal,omitempty"` - State string `json:"state,omitempty"` - Templateavailable string `json:"templateavailable,omitempty"` - Templatelimit string `json:"templatelimit,omitempty"` - Templatetotal int64 `json:"templatetotal,omitempty"` - User []struct { - Account string `json:"account,omitempty"` - Accountid string `json:"accountid,omitempty"` - Accounttype int `json:"accounttype,omitempty"` - Apikey string `json:"apikey,omitempty"` - Created string `json:"created,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Email string `json:"email,omitempty"` - Firstname string `json:"firstname,omitempty"` - Id string `json:"id,omitempty"` - Iscallerchilddomain bool `json:"iscallerchilddomain,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Lastname string `json:"lastname,omitempty"` - Secretkey string `json:"secretkey,omitempty"` - State string `json:"state,omitempty"` - Timezone string `json:"timezone,omitempty"` - Username string `json:"username,omitempty"` - } `json:"user,omitempty"` - Vmavailable string `json:"vmavailable,omitempty"` - Vmlimit string `json:"vmlimit,omitempty"` - Vmrunning int `json:"vmrunning,omitempty"` - Vmstopped int `json:"vmstopped,omitempty"` - Vmtotal int64 `json:"vmtotal,omitempty"` - Volumeavailable string `json:"volumeavailable,omitempty"` - Volumelimit string `json:"volumelimit,omitempty"` - Volumetotal int64 `json:"volumetotal,omitempty"` - Vpcavailable string `json:"vpcavailable,omitempty"` - Vpclimit string `json:"vpclimit,omitempty"` - Vpctotal int64 `json:"vpctotal,omitempty"` -} - -type DeleteAccountParams struct { - p map[string]interface{} -} - -func (p *DeleteAccountParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteAccountParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteAccountParams instance, -// as then you are sure you have configured all required params -func (s *AccountService) NewDeleteAccountParams(id string) *DeleteAccountParams { - p := &DeleteAccountParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a account, and all users associated with this account -func (s *AccountService) DeleteAccount(p *DeleteAccountParams) (*DeleteAccountResponse, error) { - resp, err := s.cs.newRequest("deleteAccount", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteAccountResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteAccountResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type UpdateAccountParams struct { - p map[string]interface{} -} - -func (p *UpdateAccountParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["accountdetails"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("accountdetails[%d].key", i), k) - u.Set(fmt.Sprintf("accountdetails[%d].value", i), vv) - i++ - } - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["networkdomain"]; found { - u.Set("networkdomain", v.(string)) - } - if v, found := p.p["newname"]; found { - u.Set("newname", v.(string)) - } - return u -} - -func (p *UpdateAccountParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *UpdateAccountParams) SetAccountdetails(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["accountdetails"] = v - return -} - -func (p *UpdateAccountParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *UpdateAccountParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateAccountParams) SetNetworkdomain(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkdomain"] = v - return -} - -func (p *UpdateAccountParams) SetNewname(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["newname"] = v - return -} - -// You should always use this function to get a new UpdateAccountParams instance, -// as then you are sure you have configured all required params -func (s *AccountService) NewUpdateAccountParams(newname string) *UpdateAccountParams { - p := &UpdateAccountParams{} - p.p = make(map[string]interface{}) - p.p["newname"] = newname - return p -} - -// Updates account information for the authenticated user -func (s *AccountService) UpdateAccount(p *UpdateAccountParams) (*UpdateAccountResponse, error) { - resp, err := s.cs.newRequest("updateAccount", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateAccountResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type UpdateAccountResponse struct { - Accountdetails map[string]string `json:"accountdetails,omitempty"` - Accounttype int `json:"accounttype,omitempty"` - Cpuavailable string `json:"cpuavailable,omitempty"` - Cpulimit string `json:"cpulimit,omitempty"` - Cputotal int64 `json:"cputotal,omitempty"` - Defaultzoneid string `json:"defaultzoneid,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Groups []string `json:"groups,omitempty"` - Id string `json:"id,omitempty"` - Ipavailable string `json:"ipavailable,omitempty"` - Iplimit string `json:"iplimit,omitempty"` - Iptotal int64 `json:"iptotal,omitempty"` - Iscleanuprequired bool `json:"iscleanuprequired,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Memoryavailable string `json:"memoryavailable,omitempty"` - Memorylimit string `json:"memorylimit,omitempty"` - Memorytotal int64 `json:"memorytotal,omitempty"` - Name string `json:"name,omitempty"` - Networkavailable string `json:"networkavailable,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Networklimit string `json:"networklimit,omitempty"` - Networktotal int64 `json:"networktotal,omitempty"` - Primarystorageavailable string `json:"primarystorageavailable,omitempty"` - Primarystoragelimit string `json:"primarystoragelimit,omitempty"` - Primarystoragetotal int64 `json:"primarystoragetotal,omitempty"` - Projectavailable string `json:"projectavailable,omitempty"` - Projectlimit string `json:"projectlimit,omitempty"` - Projecttotal int64 `json:"projecttotal,omitempty"` - Receivedbytes int64 `json:"receivedbytes,omitempty"` - Secondarystorageavailable string `json:"secondarystorageavailable,omitempty"` - Secondarystoragelimit string `json:"secondarystoragelimit,omitempty"` - Secondarystoragetotal int64 `json:"secondarystoragetotal,omitempty"` - Sentbytes int64 `json:"sentbytes,omitempty"` - Snapshotavailable string `json:"snapshotavailable,omitempty"` - Snapshotlimit string `json:"snapshotlimit,omitempty"` - Snapshottotal int64 `json:"snapshottotal,omitempty"` - State string `json:"state,omitempty"` - Templateavailable string `json:"templateavailable,omitempty"` - Templatelimit string `json:"templatelimit,omitempty"` - Templatetotal int64 `json:"templatetotal,omitempty"` - User []struct { - Account string `json:"account,omitempty"` - Accountid string `json:"accountid,omitempty"` - Accounttype int `json:"accounttype,omitempty"` - Apikey string `json:"apikey,omitempty"` - Created string `json:"created,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Email string `json:"email,omitempty"` - Firstname string `json:"firstname,omitempty"` - Id string `json:"id,omitempty"` - Iscallerchilddomain bool `json:"iscallerchilddomain,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Lastname string `json:"lastname,omitempty"` - Secretkey string `json:"secretkey,omitempty"` - State string `json:"state,omitempty"` - Timezone string `json:"timezone,omitempty"` - Username string `json:"username,omitempty"` - } `json:"user,omitempty"` - Vmavailable string `json:"vmavailable,omitempty"` - Vmlimit string `json:"vmlimit,omitempty"` - Vmrunning int `json:"vmrunning,omitempty"` - Vmstopped int `json:"vmstopped,omitempty"` - Vmtotal int64 `json:"vmtotal,omitempty"` - Volumeavailable string `json:"volumeavailable,omitempty"` - Volumelimit string `json:"volumelimit,omitempty"` - Volumetotal int64 `json:"volumetotal,omitempty"` - Vpcavailable string `json:"vpcavailable,omitempty"` - Vpclimit string `json:"vpclimit,omitempty"` - Vpctotal int64 `json:"vpctotal,omitempty"` -} - -type DisableAccountParams struct { - p map[string]interface{} -} - -func (p *DisableAccountParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["lock"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("lock", vv) - } - return u -} - -func (p *DisableAccountParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *DisableAccountParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *DisableAccountParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *DisableAccountParams) SetLock(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["lock"] = v - return -} - -// You should always use this function to get a new DisableAccountParams instance, -// as then you are sure you have configured all required params -func (s *AccountService) NewDisableAccountParams(lock bool) *DisableAccountParams { - p := &DisableAccountParams{} - p.p = make(map[string]interface{}) - p.p["lock"] = lock - return p -} - -// Disables an account -func (s *AccountService) DisableAccount(p *DisableAccountParams) (*DisableAccountResponse, error) { - resp, err := s.cs.newRequest("disableAccount", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DisableAccountResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DisableAccountResponse struct { - JobID string `json:"jobid,omitempty"` - Accountdetails map[string]string `json:"accountdetails,omitempty"` - Accounttype int `json:"accounttype,omitempty"` - Cpuavailable string `json:"cpuavailable,omitempty"` - Cpulimit string `json:"cpulimit,omitempty"` - Cputotal int64 `json:"cputotal,omitempty"` - Defaultzoneid string `json:"defaultzoneid,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Groups []string `json:"groups,omitempty"` - Id string `json:"id,omitempty"` - Ipavailable string `json:"ipavailable,omitempty"` - Iplimit string `json:"iplimit,omitempty"` - Iptotal int64 `json:"iptotal,omitempty"` - Iscleanuprequired bool `json:"iscleanuprequired,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Memoryavailable string `json:"memoryavailable,omitempty"` - Memorylimit string `json:"memorylimit,omitempty"` - Memorytotal int64 `json:"memorytotal,omitempty"` - Name string `json:"name,omitempty"` - Networkavailable string `json:"networkavailable,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Networklimit string `json:"networklimit,omitempty"` - Networktotal int64 `json:"networktotal,omitempty"` - Primarystorageavailable string `json:"primarystorageavailable,omitempty"` - Primarystoragelimit string `json:"primarystoragelimit,omitempty"` - Primarystoragetotal int64 `json:"primarystoragetotal,omitempty"` - Projectavailable string `json:"projectavailable,omitempty"` - Projectlimit string `json:"projectlimit,omitempty"` - Projecttotal int64 `json:"projecttotal,omitempty"` - Receivedbytes int64 `json:"receivedbytes,omitempty"` - Secondarystorageavailable string `json:"secondarystorageavailable,omitempty"` - Secondarystoragelimit string `json:"secondarystoragelimit,omitempty"` - Secondarystoragetotal int64 `json:"secondarystoragetotal,omitempty"` - Sentbytes int64 `json:"sentbytes,omitempty"` - Snapshotavailable string `json:"snapshotavailable,omitempty"` - Snapshotlimit string `json:"snapshotlimit,omitempty"` - Snapshottotal int64 `json:"snapshottotal,omitempty"` - State string `json:"state,omitempty"` - Templateavailable string `json:"templateavailable,omitempty"` - Templatelimit string `json:"templatelimit,omitempty"` - Templatetotal int64 `json:"templatetotal,omitempty"` - User []struct { - Account string `json:"account,omitempty"` - Accountid string `json:"accountid,omitempty"` - Accounttype int `json:"accounttype,omitempty"` - Apikey string `json:"apikey,omitempty"` - Created string `json:"created,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Email string `json:"email,omitempty"` - Firstname string `json:"firstname,omitempty"` - Id string `json:"id,omitempty"` - Iscallerchilddomain bool `json:"iscallerchilddomain,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Lastname string `json:"lastname,omitempty"` - Secretkey string `json:"secretkey,omitempty"` - State string `json:"state,omitempty"` - Timezone string `json:"timezone,omitempty"` - Username string `json:"username,omitempty"` - } `json:"user,omitempty"` - Vmavailable string `json:"vmavailable,omitempty"` - Vmlimit string `json:"vmlimit,omitempty"` - Vmrunning int `json:"vmrunning,omitempty"` - Vmstopped int `json:"vmstopped,omitempty"` - Vmtotal int64 `json:"vmtotal,omitempty"` - Volumeavailable string `json:"volumeavailable,omitempty"` - Volumelimit string `json:"volumelimit,omitempty"` - Volumetotal int64 `json:"volumetotal,omitempty"` - Vpcavailable string `json:"vpcavailable,omitempty"` - Vpclimit string `json:"vpclimit,omitempty"` - Vpctotal int64 `json:"vpctotal,omitempty"` -} - -type EnableAccountParams struct { - p map[string]interface{} -} - -func (p *EnableAccountParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *EnableAccountParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *EnableAccountParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *EnableAccountParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new EnableAccountParams instance, -// as then you are sure you have configured all required params -func (s *AccountService) NewEnableAccountParams() *EnableAccountParams { - p := &EnableAccountParams{} - p.p = make(map[string]interface{}) - return p -} - -// Enables an account -func (s *AccountService) EnableAccount(p *EnableAccountParams) (*EnableAccountResponse, error) { - resp, err := s.cs.newRequest("enableAccount", p.toURLValues()) - if err != nil { - return nil, err - } - - var r EnableAccountResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type EnableAccountResponse struct { - Accountdetails map[string]string `json:"accountdetails,omitempty"` - Accounttype int `json:"accounttype,omitempty"` - Cpuavailable string `json:"cpuavailable,omitempty"` - Cpulimit string `json:"cpulimit,omitempty"` - Cputotal int64 `json:"cputotal,omitempty"` - Defaultzoneid string `json:"defaultzoneid,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Groups []string `json:"groups,omitempty"` - Id string `json:"id,omitempty"` - Ipavailable string `json:"ipavailable,omitempty"` - Iplimit string `json:"iplimit,omitempty"` - Iptotal int64 `json:"iptotal,omitempty"` - Iscleanuprequired bool `json:"iscleanuprequired,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Memoryavailable string `json:"memoryavailable,omitempty"` - Memorylimit string `json:"memorylimit,omitempty"` - Memorytotal int64 `json:"memorytotal,omitempty"` - Name string `json:"name,omitempty"` - Networkavailable string `json:"networkavailable,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Networklimit string `json:"networklimit,omitempty"` - Networktotal int64 `json:"networktotal,omitempty"` - Primarystorageavailable string `json:"primarystorageavailable,omitempty"` - Primarystoragelimit string `json:"primarystoragelimit,omitempty"` - Primarystoragetotal int64 `json:"primarystoragetotal,omitempty"` - Projectavailable string `json:"projectavailable,omitempty"` - Projectlimit string `json:"projectlimit,omitempty"` - Projecttotal int64 `json:"projecttotal,omitempty"` - Receivedbytes int64 `json:"receivedbytes,omitempty"` - Secondarystorageavailable string `json:"secondarystorageavailable,omitempty"` - Secondarystoragelimit string `json:"secondarystoragelimit,omitempty"` - Secondarystoragetotal int64 `json:"secondarystoragetotal,omitempty"` - Sentbytes int64 `json:"sentbytes,omitempty"` - Snapshotavailable string `json:"snapshotavailable,omitempty"` - Snapshotlimit string `json:"snapshotlimit,omitempty"` - Snapshottotal int64 `json:"snapshottotal,omitempty"` - State string `json:"state,omitempty"` - Templateavailable string `json:"templateavailable,omitempty"` - Templatelimit string `json:"templatelimit,omitempty"` - Templatetotal int64 `json:"templatetotal,omitempty"` - User []struct { - Account string `json:"account,omitempty"` - Accountid string `json:"accountid,omitempty"` - Accounttype int `json:"accounttype,omitempty"` - Apikey string `json:"apikey,omitempty"` - Created string `json:"created,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Email string `json:"email,omitempty"` - Firstname string `json:"firstname,omitempty"` - Id string `json:"id,omitempty"` - Iscallerchilddomain bool `json:"iscallerchilddomain,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Lastname string `json:"lastname,omitempty"` - Secretkey string `json:"secretkey,omitempty"` - State string `json:"state,omitempty"` - Timezone string `json:"timezone,omitempty"` - Username string `json:"username,omitempty"` - } `json:"user,omitempty"` - Vmavailable string `json:"vmavailable,omitempty"` - Vmlimit string `json:"vmlimit,omitempty"` - Vmrunning int `json:"vmrunning,omitempty"` - Vmstopped int `json:"vmstopped,omitempty"` - Vmtotal int64 `json:"vmtotal,omitempty"` - Volumeavailable string `json:"volumeavailable,omitempty"` - Volumelimit string `json:"volumelimit,omitempty"` - Volumetotal int64 `json:"volumetotal,omitempty"` - Vpcavailable string `json:"vpcavailable,omitempty"` - Vpclimit string `json:"vpclimit,omitempty"` - Vpctotal int64 `json:"vpctotal,omitempty"` -} - -type LockAccountParams struct { - p map[string]interface{} -} - -func (p *LockAccountParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - return u -} - -func (p *LockAccountParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *LockAccountParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -// You should always use this function to get a new LockAccountParams instance, -// as then you are sure you have configured all required params -func (s *AccountService) NewLockAccountParams(account string, domainid string) *LockAccountParams { - p := &LockAccountParams{} - p.p = make(map[string]interface{}) - p.p["account"] = account - p.p["domainid"] = domainid - return p -} - -// This deprecated function used to locks an account. Look for the API DisableAccount instead -func (s *AccountService) LockAccount(p *LockAccountParams) (*LockAccountResponse, error) { - resp, err := s.cs.newRequest("lockAccount", p.toURLValues()) - if err != nil { - return nil, err - } - - var r LockAccountResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type LockAccountResponse struct { - Accountdetails map[string]string `json:"accountdetails,omitempty"` - Accounttype int `json:"accounttype,omitempty"` - Cpuavailable string `json:"cpuavailable,omitempty"` - Cpulimit string `json:"cpulimit,omitempty"` - Cputotal int64 `json:"cputotal,omitempty"` - Defaultzoneid string `json:"defaultzoneid,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Groups []string `json:"groups,omitempty"` - Id string `json:"id,omitempty"` - Ipavailable string `json:"ipavailable,omitempty"` - Iplimit string `json:"iplimit,omitempty"` - Iptotal int64 `json:"iptotal,omitempty"` - Iscleanuprequired bool `json:"iscleanuprequired,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Memoryavailable string `json:"memoryavailable,omitempty"` - Memorylimit string `json:"memorylimit,omitempty"` - Memorytotal int64 `json:"memorytotal,omitempty"` - Name string `json:"name,omitempty"` - Networkavailable string `json:"networkavailable,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Networklimit string `json:"networklimit,omitempty"` - Networktotal int64 `json:"networktotal,omitempty"` - Primarystorageavailable string `json:"primarystorageavailable,omitempty"` - Primarystoragelimit string `json:"primarystoragelimit,omitempty"` - Primarystoragetotal int64 `json:"primarystoragetotal,omitempty"` - Projectavailable string `json:"projectavailable,omitempty"` - Projectlimit string `json:"projectlimit,omitempty"` - Projecttotal int64 `json:"projecttotal,omitempty"` - Receivedbytes int64 `json:"receivedbytes,omitempty"` - Secondarystorageavailable string `json:"secondarystorageavailable,omitempty"` - Secondarystoragelimit string `json:"secondarystoragelimit,omitempty"` - Secondarystoragetotal int64 `json:"secondarystoragetotal,omitempty"` - Sentbytes int64 `json:"sentbytes,omitempty"` - Snapshotavailable string `json:"snapshotavailable,omitempty"` - Snapshotlimit string `json:"snapshotlimit,omitempty"` - Snapshottotal int64 `json:"snapshottotal,omitempty"` - State string `json:"state,omitempty"` - Templateavailable string `json:"templateavailable,omitempty"` - Templatelimit string `json:"templatelimit,omitempty"` - Templatetotal int64 `json:"templatetotal,omitempty"` - User []struct { - Account string `json:"account,omitempty"` - Accountid string `json:"accountid,omitempty"` - Accounttype int `json:"accounttype,omitempty"` - Apikey string `json:"apikey,omitempty"` - Created string `json:"created,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Email string `json:"email,omitempty"` - Firstname string `json:"firstname,omitempty"` - Id string `json:"id,omitempty"` - Iscallerchilddomain bool `json:"iscallerchilddomain,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Lastname string `json:"lastname,omitempty"` - Secretkey string `json:"secretkey,omitempty"` - State string `json:"state,omitempty"` - Timezone string `json:"timezone,omitempty"` - Username string `json:"username,omitempty"` - } `json:"user,omitempty"` - Vmavailable string `json:"vmavailable,omitempty"` - Vmlimit string `json:"vmlimit,omitempty"` - Vmrunning int `json:"vmrunning,omitempty"` - Vmstopped int `json:"vmstopped,omitempty"` - Vmtotal int64 `json:"vmtotal,omitempty"` - Volumeavailable string `json:"volumeavailable,omitempty"` - Volumelimit string `json:"volumelimit,omitempty"` - Volumetotal int64 `json:"volumetotal,omitempty"` - Vpcavailable string `json:"vpcavailable,omitempty"` - Vpclimit string `json:"vpclimit,omitempty"` - Vpctotal int64 `json:"vpctotal,omitempty"` -} - -type ListAccountsParams struct { - p map[string]interface{} -} - -func (p *ListAccountsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["accounttype"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("accounttype", vv) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["iscleanuprequired"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("iscleanuprequired", vv) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["state"]; found { - u.Set("state", v.(string)) - } - return u -} - -func (p *ListAccountsParams) SetAccounttype(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["accounttype"] = v - return -} - -func (p *ListAccountsParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListAccountsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListAccountsParams) SetIscleanuprequired(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["iscleanuprequired"] = v - return -} - -func (p *ListAccountsParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListAccountsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListAccountsParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListAccountsParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListAccountsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListAccountsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListAccountsParams) SetState(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["state"] = v - return -} - -// You should always use this function to get a new ListAccountsParams instance, -// as then you are sure you have configured all required params -func (s *AccountService) NewListAccountsParams() *ListAccountsParams { - p := &ListAccountsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *AccountService) GetAccountID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListAccountsParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListAccounts(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.Accounts[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.Accounts { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *AccountService) GetAccountByName(name string, opts ...OptionFunc) (*Account, int, error) { - id, count, err := s.GetAccountID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetAccountByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *AccountService) GetAccountByID(id string, opts ...OptionFunc) (*Account, int, error) { - p := &ListAccountsParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListAccounts(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.Accounts[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for Account UUID: %s!", id) -} - -// Lists accounts and provides detailed account information for listed accounts -func (s *AccountService) ListAccounts(p *ListAccountsParams) (*ListAccountsResponse, error) { - resp, err := s.cs.newRequest("listAccounts", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListAccountsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListAccountsResponse struct { - Count int `json:"count"` - Accounts []*Account `json:"account"` -} - -type Account struct { - Accountdetails map[string]string `json:"accountdetails,omitempty"` - Accounttype int `json:"accounttype,omitempty"` - Cpuavailable string `json:"cpuavailable,omitempty"` - Cpulimit string `json:"cpulimit,omitempty"` - Cputotal int64 `json:"cputotal,omitempty"` - Defaultzoneid string `json:"defaultzoneid,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Groups []string `json:"groups,omitempty"` - Id string `json:"id,omitempty"` - Ipavailable string `json:"ipavailable,omitempty"` - Iplimit string `json:"iplimit,omitempty"` - Iptotal int64 `json:"iptotal,omitempty"` - Iscleanuprequired bool `json:"iscleanuprequired,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Memoryavailable string `json:"memoryavailable,omitempty"` - Memorylimit string `json:"memorylimit,omitempty"` - Memorytotal int64 `json:"memorytotal,omitempty"` - Name string `json:"name,omitempty"` - Networkavailable string `json:"networkavailable,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Networklimit string `json:"networklimit,omitempty"` - Networktotal int64 `json:"networktotal,omitempty"` - Primarystorageavailable string `json:"primarystorageavailable,omitempty"` - Primarystoragelimit string `json:"primarystoragelimit,omitempty"` - Primarystoragetotal int64 `json:"primarystoragetotal,omitempty"` - Projectavailable string `json:"projectavailable,omitempty"` - Projectlimit string `json:"projectlimit,omitempty"` - Projecttotal int64 `json:"projecttotal,omitempty"` - Receivedbytes int64 `json:"receivedbytes,omitempty"` - Secondarystorageavailable string `json:"secondarystorageavailable,omitempty"` - Secondarystoragelimit string `json:"secondarystoragelimit,omitempty"` - Secondarystoragetotal int64 `json:"secondarystoragetotal,omitempty"` - Sentbytes int64 `json:"sentbytes,omitempty"` - Snapshotavailable string `json:"snapshotavailable,omitempty"` - Snapshotlimit string `json:"snapshotlimit,omitempty"` - Snapshottotal int64 `json:"snapshottotal,omitempty"` - State string `json:"state,omitempty"` - Templateavailable string `json:"templateavailable,omitempty"` - Templatelimit string `json:"templatelimit,omitempty"` - Templatetotal int64 `json:"templatetotal,omitempty"` - User []struct { - Account string `json:"account,omitempty"` - Accountid string `json:"accountid,omitempty"` - Accounttype int `json:"accounttype,omitempty"` - Apikey string `json:"apikey,omitempty"` - Created string `json:"created,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Email string `json:"email,omitempty"` - Firstname string `json:"firstname,omitempty"` - Id string `json:"id,omitempty"` - Iscallerchilddomain bool `json:"iscallerchilddomain,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Lastname string `json:"lastname,omitempty"` - Secretkey string `json:"secretkey,omitempty"` - State string `json:"state,omitempty"` - Timezone string `json:"timezone,omitempty"` - Username string `json:"username,omitempty"` - } `json:"user,omitempty"` - Vmavailable string `json:"vmavailable,omitempty"` - Vmlimit string `json:"vmlimit,omitempty"` - Vmrunning int `json:"vmrunning,omitempty"` - Vmstopped int `json:"vmstopped,omitempty"` - Vmtotal int64 `json:"vmtotal,omitempty"` - Volumeavailable string `json:"volumeavailable,omitempty"` - Volumelimit string `json:"volumelimit,omitempty"` - Volumetotal int64 `json:"volumetotal,omitempty"` - Vpcavailable string `json:"vpcavailable,omitempty"` - Vpclimit string `json:"vpclimit,omitempty"` - Vpctotal int64 `json:"vpctotal,omitempty"` -} - -type MarkDefaultZoneForAccountParams struct { - p map[string]interface{} -} - -func (p *MarkDefaultZoneForAccountParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *MarkDefaultZoneForAccountParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *MarkDefaultZoneForAccountParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *MarkDefaultZoneForAccountParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new MarkDefaultZoneForAccountParams instance, -// as then you are sure you have configured all required params -func (s *AccountService) NewMarkDefaultZoneForAccountParams(account string, domainid string, zoneid string) *MarkDefaultZoneForAccountParams { - p := &MarkDefaultZoneForAccountParams{} - p.p = make(map[string]interface{}) - p.p["account"] = account - p.p["domainid"] = domainid - p.p["zoneid"] = zoneid - return p -} - -// Marks a default zone for this account -func (s *AccountService) MarkDefaultZoneForAccount(p *MarkDefaultZoneForAccountParams) (*MarkDefaultZoneForAccountResponse, error) { - resp, err := s.cs.newRequest("markDefaultZoneForAccount", p.toURLValues()) - if err != nil { - return nil, err - } - - var r MarkDefaultZoneForAccountResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type MarkDefaultZoneForAccountResponse struct { - JobID string `json:"jobid,omitempty"` - Accountdetails map[string]string `json:"accountdetails,omitempty"` - Accounttype int `json:"accounttype,omitempty"` - Cpuavailable string `json:"cpuavailable,omitempty"` - Cpulimit string `json:"cpulimit,omitempty"` - Cputotal int64 `json:"cputotal,omitempty"` - Defaultzoneid string `json:"defaultzoneid,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Groups []string `json:"groups,omitempty"` - Id string `json:"id,omitempty"` - Ipavailable string `json:"ipavailable,omitempty"` - Iplimit string `json:"iplimit,omitempty"` - Iptotal int64 `json:"iptotal,omitempty"` - Iscleanuprequired bool `json:"iscleanuprequired,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Memoryavailable string `json:"memoryavailable,omitempty"` - Memorylimit string `json:"memorylimit,omitempty"` - Memorytotal int64 `json:"memorytotal,omitempty"` - Name string `json:"name,omitempty"` - Networkavailable string `json:"networkavailable,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Networklimit string `json:"networklimit,omitempty"` - Networktotal int64 `json:"networktotal,omitempty"` - Primarystorageavailable string `json:"primarystorageavailable,omitempty"` - Primarystoragelimit string `json:"primarystoragelimit,omitempty"` - Primarystoragetotal int64 `json:"primarystoragetotal,omitempty"` - Projectavailable string `json:"projectavailable,omitempty"` - Projectlimit string `json:"projectlimit,omitempty"` - Projecttotal int64 `json:"projecttotal,omitempty"` - Receivedbytes int64 `json:"receivedbytes,omitempty"` - Secondarystorageavailable string `json:"secondarystorageavailable,omitempty"` - Secondarystoragelimit string `json:"secondarystoragelimit,omitempty"` - Secondarystoragetotal int64 `json:"secondarystoragetotal,omitempty"` - Sentbytes int64 `json:"sentbytes,omitempty"` - Snapshotavailable string `json:"snapshotavailable,omitempty"` - Snapshotlimit string `json:"snapshotlimit,omitempty"` - Snapshottotal int64 `json:"snapshottotal,omitempty"` - State string `json:"state,omitempty"` - Templateavailable string `json:"templateavailable,omitempty"` - Templatelimit string `json:"templatelimit,omitempty"` - Templatetotal int64 `json:"templatetotal,omitempty"` - User []struct { - Account string `json:"account,omitempty"` - Accountid string `json:"accountid,omitempty"` - Accounttype int `json:"accounttype,omitempty"` - Apikey string `json:"apikey,omitempty"` - Created string `json:"created,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Email string `json:"email,omitempty"` - Firstname string `json:"firstname,omitempty"` - Id string `json:"id,omitempty"` - Iscallerchilddomain bool `json:"iscallerchilddomain,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Lastname string `json:"lastname,omitempty"` - Secretkey string `json:"secretkey,omitempty"` - State string `json:"state,omitempty"` - Timezone string `json:"timezone,omitempty"` - Username string `json:"username,omitempty"` - } `json:"user,omitempty"` - Vmavailable string `json:"vmavailable,omitempty"` - Vmlimit string `json:"vmlimit,omitempty"` - Vmrunning int `json:"vmrunning,omitempty"` - Vmstopped int `json:"vmstopped,omitempty"` - Vmtotal int64 `json:"vmtotal,omitempty"` - Volumeavailable string `json:"volumeavailable,omitempty"` - Volumelimit string `json:"volumelimit,omitempty"` - Volumetotal int64 `json:"volumetotal,omitempty"` - Vpcavailable string `json:"vpcavailable,omitempty"` - Vpclimit string `json:"vpclimit,omitempty"` - Vpctotal int64 `json:"vpctotal,omitempty"` -} - -type AddAccountToProjectParams struct { - p map[string]interface{} -} - -func (p *AddAccountToProjectParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["email"]; found { - u.Set("email", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - return u -} - -func (p *AddAccountToProjectParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *AddAccountToProjectParams) SetEmail(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["email"] = v - return -} - -func (p *AddAccountToProjectParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -// You should always use this function to get a new AddAccountToProjectParams instance, -// as then you are sure you have configured all required params -func (s *AccountService) NewAddAccountToProjectParams(projectid string) *AddAccountToProjectParams { - p := &AddAccountToProjectParams{} - p.p = make(map[string]interface{}) - p.p["projectid"] = projectid - return p -} - -// Adds account to a project -func (s *AccountService) AddAccountToProject(p *AddAccountToProjectParams) (*AddAccountToProjectResponse, error) { - resp, err := s.cs.newRequest("addAccountToProject", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AddAccountToProjectResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type AddAccountToProjectResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type DeleteAccountFromProjectParams struct { - p map[string]interface{} -} - -func (p *DeleteAccountFromProjectParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - return u -} - -func (p *DeleteAccountFromProjectParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *DeleteAccountFromProjectParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -// You should always use this function to get a new DeleteAccountFromProjectParams instance, -// as then you are sure you have configured all required params -func (s *AccountService) NewDeleteAccountFromProjectParams(account string, projectid string) *DeleteAccountFromProjectParams { - p := &DeleteAccountFromProjectParams{} - p.p = make(map[string]interface{}) - p.p["account"] = account - p.p["projectid"] = projectid - return p -} - -// Deletes account from the project -func (s *AccountService) DeleteAccountFromProject(p *DeleteAccountFromProjectParams) (*DeleteAccountFromProjectResponse, error) { - resp, err := s.cs.newRequest("deleteAccountFromProject", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteAccountFromProjectResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteAccountFromProjectResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListProjectAccountsParams struct { - p map[string]interface{} -} - -func (p *ListProjectAccountsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["role"]; found { - u.Set("role", v.(string)) - } - return u -} - -func (p *ListProjectAccountsParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListProjectAccountsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListProjectAccountsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListProjectAccountsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListProjectAccountsParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListProjectAccountsParams) SetRole(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["role"] = v - return -} - -// You should always use this function to get a new ListProjectAccountsParams instance, -// as then you are sure you have configured all required params -func (s *AccountService) NewListProjectAccountsParams(projectid string) *ListProjectAccountsParams { - p := &ListProjectAccountsParams{} - p.p = make(map[string]interface{}) - p.p["projectid"] = projectid - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *AccountService) GetProjectAccountID(keyword string, projectid string, opts ...OptionFunc) (string, int, error) { - p := &ListProjectAccountsParams{} - p.p = make(map[string]interface{}) - - p.p["keyword"] = keyword - p.p["projectid"] = projectid - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListProjectAccounts(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", keyword, l) - } - - if l.Count == 1 { - return l.ProjectAccounts[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.ProjectAccounts { - if v.Name == keyword { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l) -} - -// Lists project's accounts -func (s *AccountService) ListProjectAccounts(p *ListProjectAccountsParams) (*ListProjectAccountsResponse, error) { - resp, err := s.cs.newRequest("listProjectAccounts", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListProjectAccountsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListProjectAccountsResponse struct { - Count int `json:"count"` - ProjectAccounts []*ProjectAccount `json:"projectaccount"` -} - -type ProjectAccount struct { - Account string `json:"account,omitempty"` - Cpuavailable string `json:"cpuavailable,omitempty"` - Cpulimit string `json:"cpulimit,omitempty"` - Cputotal int64 `json:"cputotal,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Ipavailable string `json:"ipavailable,omitempty"` - Iplimit string `json:"iplimit,omitempty"` - Iptotal int64 `json:"iptotal,omitempty"` - Memoryavailable string `json:"memoryavailable,omitempty"` - Memorylimit string `json:"memorylimit,omitempty"` - Memorytotal int64 `json:"memorytotal,omitempty"` - Name string `json:"name,omitempty"` - Networkavailable string `json:"networkavailable,omitempty"` - Networklimit string `json:"networklimit,omitempty"` - Networktotal int64 `json:"networktotal,omitempty"` - Primarystorageavailable string `json:"primarystorageavailable,omitempty"` - Primarystoragelimit string `json:"primarystoragelimit,omitempty"` - Primarystoragetotal int64 `json:"primarystoragetotal,omitempty"` - Secondarystorageavailable string `json:"secondarystorageavailable,omitempty"` - Secondarystoragelimit string `json:"secondarystoragelimit,omitempty"` - Secondarystoragetotal int64 `json:"secondarystoragetotal,omitempty"` - Snapshotavailable string `json:"snapshotavailable,omitempty"` - Snapshotlimit string `json:"snapshotlimit,omitempty"` - Snapshottotal int64 `json:"snapshottotal,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templateavailable string `json:"templateavailable,omitempty"` - Templatelimit string `json:"templatelimit,omitempty"` - Templatetotal int64 `json:"templatetotal,omitempty"` - Vmavailable string `json:"vmavailable,omitempty"` - Vmlimit string `json:"vmlimit,omitempty"` - Vmrunning int `json:"vmrunning,omitempty"` - Vmstopped int `json:"vmstopped,omitempty"` - Vmtotal int64 `json:"vmtotal,omitempty"` - Volumeavailable string `json:"volumeavailable,omitempty"` - Volumelimit string `json:"volumelimit,omitempty"` - Volumetotal int64 `json:"volumetotal,omitempty"` - Vpcavailable string `json:"vpcavailable,omitempty"` - Vpclimit string `json:"vpclimit,omitempty"` - Vpctotal int64 `json:"vpctotal,omitempty"` -} - -type GetSolidFireAccountIdParams struct { - p map[string]interface{} -} - -func (p *GetSolidFireAccountIdParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["accountid"]; found { - u.Set("accountid", v.(string)) - } - if v, found := p.p["storageid"]; found { - u.Set("storageid", v.(string)) - } - return u -} - -func (p *GetSolidFireAccountIdParams) SetAccountid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["accountid"] = v - return -} - -func (p *GetSolidFireAccountIdParams) SetStorageid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["storageid"] = v - return -} - -// You should always use this function to get a new GetSolidFireAccountIdParams instance, -// as then you are sure you have configured all required params -func (s *AccountService) NewGetSolidFireAccountIdParams(accountid string, storageid string) *GetSolidFireAccountIdParams { - p := &GetSolidFireAccountIdParams{} - p.p = make(map[string]interface{}) - p.p["accountid"] = accountid - p.p["storageid"] = storageid - return p -} - -// Get SolidFire Account ID -func (s *AccountService) GetSolidFireAccountId(p *GetSolidFireAccountIdParams) (*GetSolidFireAccountIdResponse, error) { - resp, err := s.cs.newRequest("getSolidFireAccountId", p.toURLValues()) - if err != nil { - return nil, err - } - - var r GetSolidFireAccountIdResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type GetSolidFireAccountIdResponse struct { - SolidFireAccountId int64 `json:"solidFireAccountId,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/AddressService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/AddressService.go deleted file mode 100644 index 9ffc6d9b81d..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/AddressService.go +++ /dev/null @@ -1,811 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type AssociateIpAddressParams struct { - p map[string]interface{} -} - -func (p *AssociateIpAddressParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["isportable"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isportable", vv) - } - if v, found := p.p["networkid"]; found { - u.Set("networkid", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["regionid"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("regionid", vv) - } - if v, found := p.p["vpcid"]; found { - u.Set("vpcid", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *AssociateIpAddressParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *AssociateIpAddressParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *AssociateIpAddressParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *AssociateIpAddressParams) SetIsportable(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isportable"] = v - return -} - -func (p *AssociateIpAddressParams) SetNetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkid"] = v - return -} - -func (p *AssociateIpAddressParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *AssociateIpAddressParams) SetRegionid(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["regionid"] = v - return -} - -func (p *AssociateIpAddressParams) SetVpcid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vpcid"] = v - return -} - -func (p *AssociateIpAddressParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new AssociateIpAddressParams instance, -// as then you are sure you have configured all required params -func (s *AddressService) NewAssociateIpAddressParams() *AssociateIpAddressParams { - p := &AssociateIpAddressParams{} - p.p = make(map[string]interface{}) - return p -} - -// Acquires and associates a public IP to an account. -func (s *AddressService) AssociateIpAddress(p *AssociateIpAddressParams) (*AssociateIpAddressResponse, error) { - resp, err := s.cs.newRequest("associateIpAddress", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AssociateIpAddressResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type AssociateIpAddressResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Allocated string `json:"allocated,omitempty"` - Associatednetworkid string `json:"associatednetworkid,omitempty"` - Associatednetworkname string `json:"associatednetworkname,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isportable bool `json:"isportable,omitempty"` - Issourcenat bool `json:"issourcenat,omitempty"` - Isstaticnat bool `json:"isstaticnat,omitempty"` - Issystem bool `json:"issystem,omitempty"` - Networkid string `json:"networkid,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Purpose string `json:"purpose,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinedisplayname string `json:"virtualmachinedisplayname,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - Virtualmachinename string `json:"virtualmachinename,omitempty"` - Vlanid string `json:"vlanid,omitempty"` - Vlanname string `json:"vlanname,omitempty"` - Vmipaddress string `json:"vmipaddress,omitempty"` - Vpcid string `json:"vpcid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type DisassociateIpAddressParams struct { - p map[string]interface{} -} - -func (p *DisassociateIpAddressParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DisassociateIpAddressParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DisassociateIpAddressParams instance, -// as then you are sure you have configured all required params -func (s *AddressService) NewDisassociateIpAddressParams(id string) *DisassociateIpAddressParams { - p := &DisassociateIpAddressParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Disassociates an IP address from the account. -func (s *AddressService) DisassociateIpAddress(p *DisassociateIpAddressParams) (*DisassociateIpAddressResponse, error) { - resp, err := s.cs.newRequest("disassociateIpAddress", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DisassociateIpAddressResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DisassociateIpAddressResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListPublicIpAddressesParams struct { - p map[string]interface{} -} - -func (p *ListPublicIpAddressesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["allocatedonly"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("allocatedonly", vv) - } - if v, found := p.p["associatednetworkid"]; found { - u.Set("associatednetworkid", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["forloadbalancing"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("forloadbalancing", vv) - } - if v, found := p.p["forvirtualnetwork"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("forvirtualnetwork", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["ipaddress"]; found { - u.Set("ipaddress", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["issourcenat"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("issourcenat", vv) - } - if v, found := p.p["isstaticnat"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isstaticnat", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["physicalnetworkid"]; found { - u.Set("physicalnetworkid", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["state"]; found { - u.Set("state", v.(string)) - } - if v, found := p.p["tags"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("tags[%d].key", i), k) - u.Set(fmt.Sprintf("tags[%d].value", i), vv) - i++ - } - } - if v, found := p.p["vlanid"]; found { - u.Set("vlanid", v.(string)) - } - if v, found := p.p["vpcid"]; found { - u.Set("vpcid", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ListPublicIpAddressesParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListPublicIpAddressesParams) SetAllocatedonly(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["allocatedonly"] = v - return -} - -func (p *ListPublicIpAddressesParams) SetAssociatednetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["associatednetworkid"] = v - return -} - -func (p *ListPublicIpAddressesParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListPublicIpAddressesParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *ListPublicIpAddressesParams) SetForloadbalancing(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["forloadbalancing"] = v - return -} - -func (p *ListPublicIpAddressesParams) SetForvirtualnetwork(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["forvirtualnetwork"] = v - return -} - -func (p *ListPublicIpAddressesParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListPublicIpAddressesParams) SetIpaddress(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ipaddress"] = v - return -} - -func (p *ListPublicIpAddressesParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListPublicIpAddressesParams) SetIssourcenat(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["issourcenat"] = v - return -} - -func (p *ListPublicIpAddressesParams) SetIsstaticnat(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isstaticnat"] = v - return -} - -func (p *ListPublicIpAddressesParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListPublicIpAddressesParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListPublicIpAddressesParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListPublicIpAddressesParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListPublicIpAddressesParams) SetPhysicalnetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["physicalnetworkid"] = v - return -} - -func (p *ListPublicIpAddressesParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListPublicIpAddressesParams) SetState(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["state"] = v - return -} - -func (p *ListPublicIpAddressesParams) SetTags(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tags"] = v - return -} - -func (p *ListPublicIpAddressesParams) SetVlanid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vlanid"] = v - return -} - -func (p *ListPublicIpAddressesParams) SetVpcid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vpcid"] = v - return -} - -func (p *ListPublicIpAddressesParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ListPublicIpAddressesParams instance, -// as then you are sure you have configured all required params -func (s *AddressService) NewListPublicIpAddressesParams() *ListPublicIpAddressesParams { - p := &ListPublicIpAddressesParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *AddressService) GetPublicIpAddressByID(id string, opts ...OptionFunc) (*PublicIpAddress, int, error) { - p := &ListPublicIpAddressesParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListPublicIpAddresses(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.PublicIpAddresses[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for PublicIpAddress UUID: %s!", id) -} - -// Lists all public ip addresses -func (s *AddressService) ListPublicIpAddresses(p *ListPublicIpAddressesParams) (*ListPublicIpAddressesResponse, error) { - resp, err := s.cs.newRequest("listPublicIpAddresses", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListPublicIpAddressesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListPublicIpAddressesResponse struct { - Count int `json:"count"` - PublicIpAddresses []*PublicIpAddress `json:"publicipaddress"` -} - -type PublicIpAddress struct { - Account string `json:"account,omitempty"` - Allocated string `json:"allocated,omitempty"` - Associatednetworkid string `json:"associatednetworkid,omitempty"` - Associatednetworkname string `json:"associatednetworkname,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isportable bool `json:"isportable,omitempty"` - Issourcenat bool `json:"issourcenat,omitempty"` - Isstaticnat bool `json:"isstaticnat,omitempty"` - Issystem bool `json:"issystem,omitempty"` - Networkid string `json:"networkid,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Purpose string `json:"purpose,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinedisplayname string `json:"virtualmachinedisplayname,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - Virtualmachinename string `json:"virtualmachinename,omitempty"` - Vlanid string `json:"vlanid,omitempty"` - Vlanname string `json:"vlanname,omitempty"` - Vmipaddress string `json:"vmipaddress,omitempty"` - Vpcid string `json:"vpcid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type UpdateIpAddressParams struct { - p map[string]interface{} -} - -func (p *UpdateIpAddressParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["customid"]; found { - u.Set("customid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *UpdateIpAddressParams) SetCustomid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["customid"] = v - return -} - -func (p *UpdateIpAddressParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *UpdateIpAddressParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new UpdateIpAddressParams instance, -// as then you are sure you have configured all required params -func (s *AddressService) NewUpdateIpAddressParams(id string) *UpdateIpAddressParams { - p := &UpdateIpAddressParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates an IP address -func (s *AddressService) UpdateIpAddress(p *UpdateIpAddressParams) (*UpdateIpAddressResponse, error) { - resp, err := s.cs.newRequest("updateIpAddress", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateIpAddressResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateIpAddressResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Allocated string `json:"allocated,omitempty"` - Associatednetworkid string `json:"associatednetworkid,omitempty"` - Associatednetworkname string `json:"associatednetworkname,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isportable bool `json:"isportable,omitempty"` - Issourcenat bool `json:"issourcenat,omitempty"` - Isstaticnat bool `json:"isstaticnat,omitempty"` - Issystem bool `json:"issystem,omitempty"` - Networkid string `json:"networkid,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Purpose string `json:"purpose,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinedisplayname string `json:"virtualmachinedisplayname,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - Virtualmachinename string `json:"virtualmachinename,omitempty"` - Vlanid string `json:"vlanid,omitempty"` - Vlanname string `json:"vlanname,omitempty"` - Vmipaddress string `json:"vmipaddress,omitempty"` - Vpcid string `json:"vpcid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/AffinityGroupService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/AffinityGroupService.go deleted file mode 100644 index 600c5e47332..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/AffinityGroupService.go +++ /dev/null @@ -1,887 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type CreateAffinityGroupParams struct { - p map[string]interface{} -} - -func (p *CreateAffinityGroupParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["description"]; found { - u.Set("description", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["type"]; found { - u.Set("type", v.(string)) - } - return u -} - -func (p *CreateAffinityGroupParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *CreateAffinityGroupParams) SetDescription(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["description"] = v - return -} - -func (p *CreateAffinityGroupParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *CreateAffinityGroupParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *CreateAffinityGroupParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *CreateAffinityGroupParams) SetType(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["affinityGroupType"] = v - return -} - -// You should always use this function to get a new CreateAffinityGroupParams instance, -// as then you are sure you have configured all required params -func (s *AffinityGroupService) NewCreateAffinityGroupParams(name string, affinityGroupType string) *CreateAffinityGroupParams { - p := &CreateAffinityGroupParams{} - p.p = make(map[string]interface{}) - p.p["name"] = name - p.p["affinityGroupType"] = affinityGroupType - return p -} - -// Creates an affinity/anti-affinity group -func (s *AffinityGroupService) CreateAffinityGroup(p *CreateAffinityGroupParams) (*CreateAffinityGroupResponse, error) { - resp, err := s.cs.newRequest("createAffinityGroup", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateAffinityGroupResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateAffinityGroupResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Type string `json:"type,omitempty"` - VirtualmachineIds []string `json:"virtualmachineIds,omitempty"` -} - -type DeleteAffinityGroupParams struct { - p map[string]interface{} -} - -func (p *DeleteAffinityGroupParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - return u -} - -func (p *DeleteAffinityGroupParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *DeleteAffinityGroupParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *DeleteAffinityGroupParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *DeleteAffinityGroupParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *DeleteAffinityGroupParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -// You should always use this function to get a new DeleteAffinityGroupParams instance, -// as then you are sure you have configured all required params -func (s *AffinityGroupService) NewDeleteAffinityGroupParams() *DeleteAffinityGroupParams { - p := &DeleteAffinityGroupParams{} - p.p = make(map[string]interface{}) - return p -} - -// Deletes affinity group -func (s *AffinityGroupService) DeleteAffinityGroup(p *DeleteAffinityGroupParams) (*DeleteAffinityGroupResponse, error) { - resp, err := s.cs.newRequest("deleteAffinityGroup", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteAffinityGroupResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteAffinityGroupResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListAffinityGroupsParams struct { - p map[string]interface{} -} - -func (p *ListAffinityGroupsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["type"]; found { - u.Set("type", v.(string)) - } - if v, found := p.p["virtualmachineid"]; found { - u.Set("virtualmachineid", v.(string)) - } - return u -} - -func (p *ListAffinityGroupsParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListAffinityGroupsParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListAffinityGroupsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListAffinityGroupsParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListAffinityGroupsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListAffinityGroupsParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListAffinityGroupsParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListAffinityGroupsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListAffinityGroupsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListAffinityGroupsParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListAffinityGroupsParams) SetType(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["affinityGroupType"] = v - return -} - -func (p *ListAffinityGroupsParams) SetVirtualmachineid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["virtualmachineid"] = v - return -} - -// You should always use this function to get a new ListAffinityGroupsParams instance, -// as then you are sure you have configured all required params -func (s *AffinityGroupService) NewListAffinityGroupsParams() *ListAffinityGroupsParams { - p := &ListAffinityGroupsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *AffinityGroupService) GetAffinityGroupID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListAffinityGroupsParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListAffinityGroups(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.AffinityGroups[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.AffinityGroups { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *AffinityGroupService) GetAffinityGroupByName(name string, opts ...OptionFunc) (*AffinityGroup, int, error) { - id, count, err := s.GetAffinityGroupID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetAffinityGroupByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *AffinityGroupService) GetAffinityGroupByID(id string, opts ...OptionFunc) (*AffinityGroup, int, error) { - p := &ListAffinityGroupsParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListAffinityGroups(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.AffinityGroups[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for AffinityGroup UUID: %s!", id) -} - -// Lists affinity groups -func (s *AffinityGroupService) ListAffinityGroups(p *ListAffinityGroupsParams) (*ListAffinityGroupsResponse, error) { - resp, err := s.cs.newRequest("listAffinityGroups", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListAffinityGroupsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListAffinityGroupsResponse struct { - Count int `json:"count"` - AffinityGroups []*AffinityGroup `json:"affinitygroup"` -} - -type AffinityGroup struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Type string `json:"type,omitempty"` - VirtualmachineIds []string `json:"virtualmachineIds,omitempty"` -} - -type UpdateVMAffinityGroupParams struct { - p map[string]interface{} -} - -func (p *UpdateVMAffinityGroupParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["affinitygroupids"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("affinitygroupids", vv) - } - if v, found := p.p["affinitygroupnames"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("affinitygroupnames", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *UpdateVMAffinityGroupParams) SetAffinitygroupids(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["affinitygroupids"] = v - return -} - -func (p *UpdateVMAffinityGroupParams) SetAffinitygroupnames(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["affinitygroupnames"] = v - return -} - -func (p *UpdateVMAffinityGroupParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new UpdateVMAffinityGroupParams instance, -// as then you are sure you have configured all required params -func (s *AffinityGroupService) NewUpdateVMAffinityGroupParams(id string) *UpdateVMAffinityGroupParams { - p := &UpdateVMAffinityGroupParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates the affinity/anti-affinity group associations of a virtual machine. The VM has to be stopped and restarted for the new properties to take effect. -func (s *AffinityGroupService) UpdateVMAffinityGroup(p *UpdateVMAffinityGroupParams) (*UpdateVMAffinityGroupResponse, error) { - resp, err := s.cs.newRequest("updateVMAffinityGroup", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateVMAffinityGroupResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateVMAffinityGroupResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Affinitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Type string `json:"type,omitempty"` - VirtualmachineIds []string `json:"virtualmachineIds,omitempty"` - } `json:"affinitygroup,omitempty"` - Cpunumber int `json:"cpunumber,omitempty"` - Cpuspeed int `json:"cpuspeed,omitempty"` - Cpuused string `json:"cpuused,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Diskioread int64 `json:"diskioread,omitempty"` - Diskiowrite int64 `json:"diskiowrite,omitempty"` - Diskkbsread int64 `json:"diskkbsread,omitempty"` - Diskkbswrite int64 `json:"diskkbswrite,omitempty"` - Diskofferingid string `json:"diskofferingid,omitempty"` - Diskofferingname string `json:"diskofferingname,omitempty"` - Displayname string `json:"displayname,omitempty"` - Displayvm bool `json:"displayvm,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"` - Group string `json:"group,omitempty"` - Groupid string `json:"groupid,omitempty"` - Guestosid string `json:"guestosid,omitempty"` - Haenable bool `json:"haenable,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Instancename string `json:"instancename,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isodisplaytext string `json:"isodisplaytext,omitempty"` - Isoid string `json:"isoid,omitempty"` - Isoname string `json:"isoname,omitempty"` - Keypair string `json:"keypair,omitempty"` - Memory int `json:"memory,omitempty"` - Name string `json:"name,omitempty"` - Networkkbsread int64 `json:"networkkbsread,omitempty"` - Networkkbswrite int64 `json:"networkkbswrite,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Ostypeid int64 `json:"ostypeid,omitempty"` - Password string `json:"password,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - Rootdeviceid int64 `json:"rootdeviceid,omitempty"` - Rootdevicetype string `json:"rootdevicetype,omitempty"` - Securitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Egressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"egressrule,omitempty"` - Id string `json:"id,omitempty"` - Ingressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"ingressrule,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinecount int `json:"virtualmachinecount,omitempty"` - Virtualmachineids []string `json:"virtualmachineids,omitempty"` - } `json:"securitygroup,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - Servicestate string `json:"servicestate,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatedisplaytext string `json:"templatedisplaytext,omitempty"` - Templateid string `json:"templateid,omitempty"` - Templatename string `json:"templatename,omitempty"` - Userid string `json:"userid,omitempty"` - Username string `json:"username,omitempty"` - Vgpu string `json:"vgpu,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type ListAffinityGroupTypesParams struct { - p map[string]interface{} -} - -func (p *ListAffinityGroupTypesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - return u -} - -func (p *ListAffinityGroupTypesParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListAffinityGroupTypesParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListAffinityGroupTypesParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -// You should always use this function to get a new ListAffinityGroupTypesParams instance, -// as then you are sure you have configured all required params -func (s *AffinityGroupService) NewListAffinityGroupTypesParams() *ListAffinityGroupTypesParams { - p := &ListAffinityGroupTypesParams{} - p.p = make(map[string]interface{}) - return p -} - -// Lists affinity group types available -func (s *AffinityGroupService) ListAffinityGroupTypes(p *ListAffinityGroupTypesParams) (*ListAffinityGroupTypesResponse, error) { - resp, err := s.cs.newRequest("listAffinityGroupTypes", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListAffinityGroupTypesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListAffinityGroupTypesResponse struct { - Count int `json:"count"` - AffinityGroupTypes []*AffinityGroupType `json:"affinitygrouptype"` -} - -type AffinityGroupType struct { - Type string `json:"type,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/AlertService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/AlertService.go deleted file mode 100644 index e11b4f1901f..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/AlertService.go +++ /dev/null @@ -1,505 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type ListAlertsParams struct { - p map[string]interface{} -} - -func (p *ListAlertsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["type"]; found { - u.Set("type", v.(string)) - } - return u -} - -func (p *ListAlertsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListAlertsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListAlertsParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListAlertsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListAlertsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListAlertsParams) SetType(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["alertType"] = v - return -} - -// You should always use this function to get a new ListAlertsParams instance, -// as then you are sure you have configured all required params -func (s *AlertService) NewListAlertsParams() *ListAlertsParams { - p := &ListAlertsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *AlertService) GetAlertID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListAlertsParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListAlerts(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.Alerts[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.Alerts { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *AlertService) GetAlertByName(name string, opts ...OptionFunc) (*Alert, int, error) { - id, count, err := s.GetAlertID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetAlertByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *AlertService) GetAlertByID(id string, opts ...OptionFunc) (*Alert, int, error) { - p := &ListAlertsParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListAlerts(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.Alerts[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for Alert UUID: %s!", id) -} - -// Lists all alerts. -func (s *AlertService) ListAlerts(p *ListAlertsParams) (*ListAlertsResponse, error) { - resp, err := s.cs.newRequest("listAlerts", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListAlertsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListAlertsResponse struct { - Count int `json:"count"` - Alerts []*Alert `json:"alert"` -} - -type Alert struct { - Description string `json:"description,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Sent string `json:"sent,omitempty"` - Type int `json:"type,omitempty"` -} - -type ArchiveAlertsParams struct { - p map[string]interface{} -} - -func (p *ArchiveAlertsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["enddate"]; found { - u.Set("enddate", v.(string)) - } - if v, found := p.p["ids"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("ids", vv) - } - if v, found := p.p["startdate"]; found { - u.Set("startdate", v.(string)) - } - if v, found := p.p["type"]; found { - u.Set("type", v.(string)) - } - return u -} - -func (p *ArchiveAlertsParams) SetEnddate(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["enddate"] = v - return -} - -func (p *ArchiveAlertsParams) SetIds(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ids"] = v - return -} - -func (p *ArchiveAlertsParams) SetStartdate(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["startdate"] = v - return -} - -func (p *ArchiveAlertsParams) SetType(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["alertType"] = v - return -} - -// You should always use this function to get a new ArchiveAlertsParams instance, -// as then you are sure you have configured all required params -func (s *AlertService) NewArchiveAlertsParams() *ArchiveAlertsParams { - p := &ArchiveAlertsParams{} - p.p = make(map[string]interface{}) - return p -} - -// Archive one or more alerts. -func (s *AlertService) ArchiveAlerts(p *ArchiveAlertsParams) (*ArchiveAlertsResponse, error) { - resp, err := s.cs.newRequest("archiveAlerts", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ArchiveAlertsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ArchiveAlertsResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} - -type DeleteAlertsParams struct { - p map[string]interface{} -} - -func (p *DeleteAlertsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["enddate"]; found { - u.Set("enddate", v.(string)) - } - if v, found := p.p["ids"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("ids", vv) - } - if v, found := p.p["startdate"]; found { - u.Set("startdate", v.(string)) - } - if v, found := p.p["type"]; found { - u.Set("type", v.(string)) - } - return u -} - -func (p *DeleteAlertsParams) SetEnddate(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["enddate"] = v - return -} - -func (p *DeleteAlertsParams) SetIds(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ids"] = v - return -} - -func (p *DeleteAlertsParams) SetStartdate(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["startdate"] = v - return -} - -func (p *DeleteAlertsParams) SetType(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["alertType"] = v - return -} - -// You should always use this function to get a new DeleteAlertsParams instance, -// as then you are sure you have configured all required params -func (s *AlertService) NewDeleteAlertsParams() *DeleteAlertsParams { - p := &DeleteAlertsParams{} - p.p = make(map[string]interface{}) - return p -} - -// Delete one or more alerts. -func (s *AlertService) DeleteAlerts(p *DeleteAlertsParams) (*DeleteAlertsResponse, error) { - resp, err := s.cs.newRequest("deleteAlerts", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteAlertsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type DeleteAlertsResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} - -type GenerateAlertParams struct { - p map[string]interface{} -} - -func (p *GenerateAlertParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["description"]; found { - u.Set("description", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["podid"]; found { - u.Set("podid", v.(string)) - } - if v, found := p.p["type"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("type", vv) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *GenerateAlertParams) SetDescription(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["description"] = v - return -} - -func (p *GenerateAlertParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *GenerateAlertParams) SetPodid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["podid"] = v - return -} - -func (p *GenerateAlertParams) SetType(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["alertType"] = v - return -} - -func (p *GenerateAlertParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new GenerateAlertParams instance, -// as then you are sure you have configured all required params -func (s *AlertService) NewGenerateAlertParams(description string, name string, alertType int) *GenerateAlertParams { - p := &GenerateAlertParams{} - p.p = make(map[string]interface{}) - p.p["description"] = description - p.p["name"] = name - p.p["alertType"] = alertType - return p -} - -// Generates an alert -func (s *AlertService) GenerateAlert(p *GenerateAlertParams) (*GenerateAlertResponse, error) { - resp, err := s.cs.newRequest("generateAlert", p.toURLValues()) - if err != nil { - return nil, err - } - - var r GenerateAlertResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type GenerateAlertResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/AsyncjobService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/AsyncjobService.go deleted file mode 100644 index b3e1fd89a91..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/AsyncjobService.go +++ /dev/null @@ -1,239 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "net/url" - "strconv" - "time" -) - -type QueryAsyncJobResultParams struct { - p map[string]interface{} -} - -func (p *QueryAsyncJobResultParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["jobid"]; found { - u.Set("jobid", v.(string)) - } - return u -} - -func (p *QueryAsyncJobResultParams) SetJobid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["jobid"] = v - return -} - -// You should always use this function to get a new QueryAsyncJobResultParams instance, -// as then you are sure you have configured all required params -func (s *AsyncjobService) NewQueryAsyncJobResultParams(jobid string) *QueryAsyncJobResultParams { - p := &QueryAsyncJobResultParams{} - p.p = make(map[string]interface{}) - p.p["jobid"] = jobid - return p -} - -// Retrieves the current status of asynchronous job. -func (s *AsyncjobService) QueryAsyncJobResult(p *QueryAsyncJobResultParams) (*QueryAsyncJobResultResponse, error) { - var resp json.RawMessage - var err error - - // We should be able to retry on failure as this call is idempotent - for i := 0; i < 3; i++ { - resp, err = s.cs.newRequest("queryAsyncJobResult", p.toURLValues()) - if err == nil { - break - } - time.Sleep(500 * time.Millisecond) - } - if err != nil { - return nil, err - } - - var r QueryAsyncJobResultResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type QueryAsyncJobResultResponse struct { - Accountid string `json:"accountid,omitempty"` - Cmd string `json:"cmd,omitempty"` - Created string `json:"created,omitempty"` - Jobinstanceid string `json:"jobinstanceid,omitempty"` - Jobinstancetype string `json:"jobinstancetype,omitempty"` - Jobprocstatus int `json:"jobprocstatus,omitempty"` - Jobresult json.RawMessage `json:"jobresult,omitempty"` - Jobresultcode int `json:"jobresultcode,omitempty"` - Jobresulttype string `json:"jobresulttype,omitempty"` - Jobstatus int `json:"jobstatus,omitempty"` - Userid string `json:"userid,omitempty"` -} - -type ListAsyncJobsParams struct { - p map[string]interface{} -} - -func (p *ListAsyncJobsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["startdate"]; found { - u.Set("startdate", v.(string)) - } - return u -} - -func (p *ListAsyncJobsParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListAsyncJobsParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListAsyncJobsParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListAsyncJobsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListAsyncJobsParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListAsyncJobsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListAsyncJobsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListAsyncJobsParams) SetStartdate(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["startdate"] = v - return -} - -// You should always use this function to get a new ListAsyncJobsParams instance, -// as then you are sure you have configured all required params -func (s *AsyncjobService) NewListAsyncJobsParams() *ListAsyncJobsParams { - p := &ListAsyncJobsParams{} - p.p = make(map[string]interface{}) - return p -} - -// Lists all pending asynchronous jobs for the account. -func (s *AsyncjobService) ListAsyncJobs(p *ListAsyncJobsParams) (*ListAsyncJobsResponse, error) { - resp, err := s.cs.newRequest("listAsyncJobs", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListAsyncJobsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListAsyncJobsResponse struct { - Count int `json:"count"` - AsyncJobs []*AsyncJob `json:"asyncjobs"` -} - -type AsyncJob struct { - Accountid string `json:"accountid,omitempty"` - Cmd string `json:"cmd,omitempty"` - Created string `json:"created,omitempty"` - Jobinstanceid string `json:"jobinstanceid,omitempty"` - Jobinstancetype string `json:"jobinstancetype,omitempty"` - Jobprocstatus int `json:"jobprocstatus,omitempty"` - Jobresult json.RawMessage `json:"jobresult,omitempty"` - Jobresultcode int `json:"jobresultcode,omitempty"` - Jobresulttype string `json:"jobresulttype,omitempty"` - Jobstatus int `json:"jobstatus,omitempty"` - Userid string `json:"userid,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/AuthenticationService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/AuthenticationService.go deleted file mode 100644 index b97e70cfac1..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/AuthenticationService.go +++ /dev/null @@ -1,156 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "net/url" - "strconv" -) - -type LoginParams struct { - p map[string]interface{} -} - -func (p *LoginParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["domain"]; found { - u.Set("domain", v.(string)) - } - if v, found := p.p["domainId"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("domainId", vv) - } - if v, found := p.p["password"]; found { - u.Set("password", v.(string)) - } - if v, found := p.p["username"]; found { - u.Set("username", v.(string)) - } - return u -} - -func (p *LoginParams) SetDomain(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domain"] = v - return -} - -func (p *LoginParams) SetDomainId(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainId"] = v - return -} - -func (p *LoginParams) SetPassword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["password"] = v - return -} - -func (p *LoginParams) SetUsername(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["username"] = v - return -} - -// You should always use this function to get a new LoginParams instance, -// as then you are sure you have configured all required params -func (s *AuthenticationService) NewLoginParams(password string, username string) *LoginParams { - p := &LoginParams{} - p.p = make(map[string]interface{}) - p.p["password"] = password - p.p["username"] = username - return p -} - -// Logs a user into the CloudStack. A successful login attempt will generate a JSESSIONID cookie value that can be passed in subsequent Query command calls until the "logout" command has been issued or the session has expired. -func (s *AuthenticationService) Login(p *LoginParams) (*LoginResponse, error) { - resp, err := s.cs.newRequest("login", p.toURLValues()) - if err != nil { - return nil, err - } - - var r LoginResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type LoginResponse struct { - Account string `json:"account,omitempty"` - Domainid string `json:"domainid,omitempty"` - Firstname string `json:"firstname,omitempty"` - Lastname string `json:"lastname,omitempty"` - Registered string `json:"registered,omitempty"` - Sessionkey string `json:"sessionkey,omitempty"` - Timeout int `json:"timeout,omitempty"` - Timezone string `json:"timezone,omitempty"` - Type string `json:"type,omitempty"` - Userid string `json:"userid,omitempty"` - Username string `json:"username,omitempty"` -} - -type LogoutParams struct { - p map[string]interface{} -} - -func (p *LogoutParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - return u -} - -// You should always use this function to get a new LogoutParams instance, -// as then you are sure you have configured all required params -func (s *AuthenticationService) NewLogoutParams() *LogoutParams { - p := &LogoutParams{} - p.p = make(map[string]interface{}) - return p -} - -// Logs out the user -func (s *AuthenticationService) Logout(p *LogoutParams) (*LogoutResponse, error) { - resp, err := s.cs.newRequest("logout", p.toURLValues()) - if err != nil { - return nil, err - } - - var r LogoutResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type LogoutResponse struct { - Description string `json:"description,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/AutoScaleService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/AutoScaleService.go deleted file mode 100644 index 27e328616ea..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/AutoScaleService.go +++ /dev/null @@ -1,2759 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type CreateCounterParams struct { - p map[string]interface{} -} - -func (p *CreateCounterParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["source"]; found { - u.Set("source", v.(string)) - } - if v, found := p.p["value"]; found { - u.Set("value", v.(string)) - } - return u -} - -func (p *CreateCounterParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *CreateCounterParams) SetSource(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["source"] = v - return -} - -func (p *CreateCounterParams) SetValue(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["value"] = v - return -} - -// You should always use this function to get a new CreateCounterParams instance, -// as then you are sure you have configured all required params -func (s *AutoScaleService) NewCreateCounterParams(name string, source string, value string) *CreateCounterParams { - p := &CreateCounterParams{} - p.p = make(map[string]interface{}) - p.p["name"] = name - p.p["source"] = source - p.p["value"] = value - return p -} - -// Adds metric counter -func (s *AutoScaleService) CreateCounter(p *CreateCounterParams) (*CreateCounterResponse, error) { - resp, err := s.cs.newRequest("createCounter", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateCounterResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateCounterResponse struct { - JobID string `json:"jobid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Source string `json:"source,omitempty"` - Value string `json:"value,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type CreateConditionParams struct { - p map[string]interface{} -} - -func (p *CreateConditionParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["counterid"]; found { - u.Set("counterid", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["relationaloperator"]; found { - u.Set("relationaloperator", v.(string)) - } - if v, found := p.p["threshold"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("threshold", vv) - } - return u -} - -func (p *CreateConditionParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *CreateConditionParams) SetCounterid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["counterid"] = v - return -} - -func (p *CreateConditionParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *CreateConditionParams) SetRelationaloperator(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["relationaloperator"] = v - return -} - -func (p *CreateConditionParams) SetThreshold(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["threshold"] = v - return -} - -// You should always use this function to get a new CreateConditionParams instance, -// as then you are sure you have configured all required params -func (s *AutoScaleService) NewCreateConditionParams(counterid string, relationaloperator string, threshold int64) *CreateConditionParams { - p := &CreateConditionParams{} - p.p = make(map[string]interface{}) - p.p["counterid"] = counterid - p.p["relationaloperator"] = relationaloperator - p.p["threshold"] = threshold - return p -} - -// Creates a condition -func (s *AutoScaleService) CreateCondition(p *CreateConditionParams) (*CreateConditionResponse, error) { - resp, err := s.cs.newRequest("createCondition", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateConditionResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateConditionResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Counter []string `json:"counter,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Relationaloperator string `json:"relationaloperator,omitempty"` - Threshold int64 `json:"threshold,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type CreateAutoScalePolicyParams struct { - p map[string]interface{} -} - -func (p *CreateAutoScalePolicyParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["action"]; found { - u.Set("action", v.(string)) - } - if v, found := p.p["conditionids"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("conditionids", vv) - } - if v, found := p.p["duration"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("duration", vv) - } - if v, found := p.p["quiettime"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("quiettime", vv) - } - return u -} - -func (p *CreateAutoScalePolicyParams) SetAction(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["action"] = v - return -} - -func (p *CreateAutoScalePolicyParams) SetConditionids(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["conditionids"] = v - return -} - -func (p *CreateAutoScalePolicyParams) SetDuration(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["duration"] = v - return -} - -func (p *CreateAutoScalePolicyParams) SetQuiettime(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["quiettime"] = v - return -} - -// You should always use this function to get a new CreateAutoScalePolicyParams instance, -// as then you are sure you have configured all required params -func (s *AutoScaleService) NewCreateAutoScalePolicyParams(action string, conditionids []string, duration int) *CreateAutoScalePolicyParams { - p := &CreateAutoScalePolicyParams{} - p.p = make(map[string]interface{}) - p.p["action"] = action - p.p["conditionids"] = conditionids - p.p["duration"] = duration - return p -} - -// Creates an autoscale policy for a provision or deprovision action, the action is taken when the all the conditions evaluates to true for the specified duration. The policy is in effect once it is attached to a autscale vm group. -func (s *AutoScaleService) CreateAutoScalePolicy(p *CreateAutoScalePolicyParams) (*CreateAutoScalePolicyResponse, error) { - resp, err := s.cs.newRequest("createAutoScalePolicy", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateAutoScalePolicyResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateAutoScalePolicyResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Action string `json:"action,omitempty"` - Conditions []string `json:"conditions,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Duration int `json:"duration,omitempty"` - Id string `json:"id,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Quiettime int `json:"quiettime,omitempty"` -} - -type CreateAutoScaleVmProfileParams struct { - p map[string]interface{} -} - -func (p *CreateAutoScaleVmProfileParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["autoscaleuserid"]; found { - u.Set("autoscaleuserid", v.(string)) - } - if v, found := p.p["counterparam"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("counterparam[%d].key", i), k) - u.Set(fmt.Sprintf("counterparam[%d].value", i), vv) - i++ - } - } - if v, found := p.p["destroyvmgraceperiod"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("destroyvmgraceperiod", vv) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["otherdeployparams"]; found { - u.Set("otherdeployparams", v.(string)) - } - if v, found := p.p["serviceofferingid"]; found { - u.Set("serviceofferingid", v.(string)) - } - if v, found := p.p["templateid"]; found { - u.Set("templateid", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *CreateAutoScaleVmProfileParams) SetAutoscaleuserid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["autoscaleuserid"] = v - return -} - -func (p *CreateAutoScaleVmProfileParams) SetCounterparam(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["counterparam"] = v - return -} - -func (p *CreateAutoScaleVmProfileParams) SetDestroyvmgraceperiod(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["destroyvmgraceperiod"] = v - return -} - -func (p *CreateAutoScaleVmProfileParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *CreateAutoScaleVmProfileParams) SetOtherdeployparams(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["otherdeployparams"] = v - return -} - -func (p *CreateAutoScaleVmProfileParams) SetServiceofferingid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["serviceofferingid"] = v - return -} - -func (p *CreateAutoScaleVmProfileParams) SetTemplateid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["templateid"] = v - return -} - -func (p *CreateAutoScaleVmProfileParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new CreateAutoScaleVmProfileParams instance, -// as then you are sure you have configured all required params -func (s *AutoScaleService) NewCreateAutoScaleVmProfileParams(serviceofferingid string, templateid string, zoneid string) *CreateAutoScaleVmProfileParams { - p := &CreateAutoScaleVmProfileParams{} - p.p = make(map[string]interface{}) - p.p["serviceofferingid"] = serviceofferingid - p.p["templateid"] = templateid - p.p["zoneid"] = zoneid - return p -} - -// Creates a profile that contains information about the virtual machine which will be provisioned automatically by autoscale feature. -func (s *AutoScaleService) CreateAutoScaleVmProfile(p *CreateAutoScaleVmProfileParams) (*CreateAutoScaleVmProfileResponse, error) { - resp, err := s.cs.newRequest("createAutoScaleVmProfile", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateAutoScaleVmProfileResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateAutoScaleVmProfileResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Autoscaleuserid string `json:"autoscaleuserid,omitempty"` - Destroyvmgraceperiod int `json:"destroyvmgraceperiod,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Otherdeployparams string `json:"otherdeployparams,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Templateid string `json:"templateid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type CreateAutoScaleVmGroupParams struct { - p map[string]interface{} -} - -func (p *CreateAutoScaleVmGroupParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["interval"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("interval", vv) - } - if v, found := p.p["lbruleid"]; found { - u.Set("lbruleid", v.(string)) - } - if v, found := p.p["maxmembers"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("maxmembers", vv) - } - if v, found := p.p["minmembers"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("minmembers", vv) - } - if v, found := p.p["scaledownpolicyids"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("scaledownpolicyids", vv) - } - if v, found := p.p["scaleuppolicyids"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("scaleuppolicyids", vv) - } - if v, found := p.p["vmprofileid"]; found { - u.Set("vmprofileid", v.(string)) - } - return u -} - -func (p *CreateAutoScaleVmGroupParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *CreateAutoScaleVmGroupParams) SetInterval(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["interval"] = v - return -} - -func (p *CreateAutoScaleVmGroupParams) SetLbruleid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["lbruleid"] = v - return -} - -func (p *CreateAutoScaleVmGroupParams) SetMaxmembers(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["maxmembers"] = v - return -} - -func (p *CreateAutoScaleVmGroupParams) SetMinmembers(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["minmembers"] = v - return -} - -func (p *CreateAutoScaleVmGroupParams) SetScaledownpolicyids(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["scaledownpolicyids"] = v - return -} - -func (p *CreateAutoScaleVmGroupParams) SetScaleuppolicyids(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["scaleuppolicyids"] = v - return -} - -func (p *CreateAutoScaleVmGroupParams) SetVmprofileid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vmprofileid"] = v - return -} - -// You should always use this function to get a new CreateAutoScaleVmGroupParams instance, -// as then you are sure you have configured all required params -func (s *AutoScaleService) NewCreateAutoScaleVmGroupParams(lbruleid string, maxmembers int, minmembers int, scaledownpolicyids []string, scaleuppolicyids []string, vmprofileid string) *CreateAutoScaleVmGroupParams { - p := &CreateAutoScaleVmGroupParams{} - p.p = make(map[string]interface{}) - p.p["lbruleid"] = lbruleid - p.p["maxmembers"] = maxmembers - p.p["minmembers"] = minmembers - p.p["scaledownpolicyids"] = scaledownpolicyids - p.p["scaleuppolicyids"] = scaleuppolicyids - p.p["vmprofileid"] = vmprofileid - return p -} - -// Creates and automatically starts a virtual machine based on a service offering, disk offering, and template. -func (s *AutoScaleService) CreateAutoScaleVmGroup(p *CreateAutoScaleVmGroupParams) (*CreateAutoScaleVmGroupResponse, error) { - resp, err := s.cs.newRequest("createAutoScaleVmGroup", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateAutoScaleVmGroupResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateAutoScaleVmGroupResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Interval int `json:"interval,omitempty"` - Lbruleid string `json:"lbruleid,omitempty"` - Maxmembers int `json:"maxmembers,omitempty"` - Minmembers int `json:"minmembers,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Scaledownpolicies []string `json:"scaledownpolicies,omitempty"` - Scaleuppolicies []string `json:"scaleuppolicies,omitempty"` - State string `json:"state,omitempty"` - Vmprofileid string `json:"vmprofileid,omitempty"` -} - -type DeleteCounterParams struct { - p map[string]interface{} -} - -func (p *DeleteCounterParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteCounterParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteCounterParams instance, -// as then you are sure you have configured all required params -func (s *AutoScaleService) NewDeleteCounterParams(id string) *DeleteCounterParams { - p := &DeleteCounterParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a counter -func (s *AutoScaleService) DeleteCounter(p *DeleteCounterParams) (*DeleteCounterResponse, error) { - resp, err := s.cs.newRequest("deleteCounter", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteCounterResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteCounterResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type DeleteConditionParams struct { - p map[string]interface{} -} - -func (p *DeleteConditionParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteConditionParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteConditionParams instance, -// as then you are sure you have configured all required params -func (s *AutoScaleService) NewDeleteConditionParams(id string) *DeleteConditionParams { - p := &DeleteConditionParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Removes a condition -func (s *AutoScaleService) DeleteCondition(p *DeleteConditionParams) (*DeleteConditionResponse, error) { - resp, err := s.cs.newRequest("deleteCondition", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteConditionResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteConditionResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type DeleteAutoScalePolicyParams struct { - p map[string]interface{} -} - -func (p *DeleteAutoScalePolicyParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteAutoScalePolicyParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteAutoScalePolicyParams instance, -// as then you are sure you have configured all required params -func (s *AutoScaleService) NewDeleteAutoScalePolicyParams(id string) *DeleteAutoScalePolicyParams { - p := &DeleteAutoScalePolicyParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a autoscale policy. -func (s *AutoScaleService) DeleteAutoScalePolicy(p *DeleteAutoScalePolicyParams) (*DeleteAutoScalePolicyResponse, error) { - resp, err := s.cs.newRequest("deleteAutoScalePolicy", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteAutoScalePolicyResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteAutoScalePolicyResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type DeleteAutoScaleVmProfileParams struct { - p map[string]interface{} -} - -func (p *DeleteAutoScaleVmProfileParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteAutoScaleVmProfileParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteAutoScaleVmProfileParams instance, -// as then you are sure you have configured all required params -func (s *AutoScaleService) NewDeleteAutoScaleVmProfileParams(id string) *DeleteAutoScaleVmProfileParams { - p := &DeleteAutoScaleVmProfileParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a autoscale vm profile. -func (s *AutoScaleService) DeleteAutoScaleVmProfile(p *DeleteAutoScaleVmProfileParams) (*DeleteAutoScaleVmProfileResponse, error) { - resp, err := s.cs.newRequest("deleteAutoScaleVmProfile", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteAutoScaleVmProfileResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteAutoScaleVmProfileResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type DeleteAutoScaleVmGroupParams struct { - p map[string]interface{} -} - -func (p *DeleteAutoScaleVmGroupParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteAutoScaleVmGroupParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteAutoScaleVmGroupParams instance, -// as then you are sure you have configured all required params -func (s *AutoScaleService) NewDeleteAutoScaleVmGroupParams(id string) *DeleteAutoScaleVmGroupParams { - p := &DeleteAutoScaleVmGroupParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a autoscale vm group. -func (s *AutoScaleService) DeleteAutoScaleVmGroup(p *DeleteAutoScaleVmGroupParams) (*DeleteAutoScaleVmGroupResponse, error) { - resp, err := s.cs.newRequest("deleteAutoScaleVmGroup", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteAutoScaleVmGroupResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteAutoScaleVmGroupResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListCountersParams struct { - p map[string]interface{} -} - -func (p *ListCountersParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["source"]; found { - u.Set("source", v.(string)) - } - return u -} - -func (p *ListCountersParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListCountersParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListCountersParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListCountersParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListCountersParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListCountersParams) SetSource(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["source"] = v - return -} - -// You should always use this function to get a new ListCountersParams instance, -// as then you are sure you have configured all required params -func (s *AutoScaleService) NewListCountersParams() *ListCountersParams { - p := &ListCountersParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *AutoScaleService) GetCounterID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListCountersParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListCounters(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.Counters[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.Counters { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *AutoScaleService) GetCounterByName(name string, opts ...OptionFunc) (*Counter, int, error) { - id, count, err := s.GetCounterID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetCounterByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *AutoScaleService) GetCounterByID(id string, opts ...OptionFunc) (*Counter, int, error) { - p := &ListCountersParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListCounters(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.Counters[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for Counter UUID: %s!", id) -} - -// List the counters -func (s *AutoScaleService) ListCounters(p *ListCountersParams) (*ListCountersResponse, error) { - resp, err := s.cs.newRequest("listCounters", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListCountersResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListCountersResponse struct { - Count int `json:"count"` - Counters []*Counter `json:"counter"` -} - -type Counter struct { - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Source string `json:"source,omitempty"` - Value string `json:"value,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type ListConditionsParams struct { - p map[string]interface{} -} - -func (p *ListConditionsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["counterid"]; found { - u.Set("counterid", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["policyid"]; found { - u.Set("policyid", v.(string)) - } - return u -} - -func (p *ListConditionsParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListConditionsParams) SetCounterid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["counterid"] = v - return -} - -func (p *ListConditionsParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListConditionsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListConditionsParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListConditionsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListConditionsParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListConditionsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListConditionsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListConditionsParams) SetPolicyid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["policyid"] = v - return -} - -// You should always use this function to get a new ListConditionsParams instance, -// as then you are sure you have configured all required params -func (s *AutoScaleService) NewListConditionsParams() *ListConditionsParams { - p := &ListConditionsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *AutoScaleService) GetConditionByID(id string, opts ...OptionFunc) (*Condition, int, error) { - p := &ListConditionsParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListConditions(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.Conditions[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for Condition UUID: %s!", id) -} - -// List Conditions for the specific user -func (s *AutoScaleService) ListConditions(p *ListConditionsParams) (*ListConditionsResponse, error) { - resp, err := s.cs.newRequest("listConditions", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListConditionsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListConditionsResponse struct { - Count int `json:"count"` - Conditions []*Condition `json:"condition"` -} - -type Condition struct { - Account string `json:"account,omitempty"` - Counter []string `json:"counter,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Relationaloperator string `json:"relationaloperator,omitempty"` - Threshold int64 `json:"threshold,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type ListAutoScalePoliciesParams struct { - p map[string]interface{} -} - -func (p *ListAutoScalePoliciesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["action"]; found { - u.Set("action", v.(string)) - } - if v, found := p.p["conditionid"]; found { - u.Set("conditionid", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["vmgroupid"]; found { - u.Set("vmgroupid", v.(string)) - } - return u -} - -func (p *ListAutoScalePoliciesParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListAutoScalePoliciesParams) SetAction(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["action"] = v - return -} - -func (p *ListAutoScalePoliciesParams) SetConditionid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["conditionid"] = v - return -} - -func (p *ListAutoScalePoliciesParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListAutoScalePoliciesParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListAutoScalePoliciesParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListAutoScalePoliciesParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListAutoScalePoliciesParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListAutoScalePoliciesParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListAutoScalePoliciesParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListAutoScalePoliciesParams) SetVmgroupid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vmgroupid"] = v - return -} - -// You should always use this function to get a new ListAutoScalePoliciesParams instance, -// as then you are sure you have configured all required params -func (s *AutoScaleService) NewListAutoScalePoliciesParams() *ListAutoScalePoliciesParams { - p := &ListAutoScalePoliciesParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *AutoScaleService) GetAutoScalePolicyByID(id string, opts ...OptionFunc) (*AutoScalePolicy, int, error) { - p := &ListAutoScalePoliciesParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListAutoScalePolicies(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.AutoScalePolicies[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for AutoScalePolicy UUID: %s!", id) -} - -// Lists autoscale policies. -func (s *AutoScaleService) ListAutoScalePolicies(p *ListAutoScalePoliciesParams) (*ListAutoScalePoliciesResponse, error) { - resp, err := s.cs.newRequest("listAutoScalePolicies", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListAutoScalePoliciesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListAutoScalePoliciesResponse struct { - Count int `json:"count"` - AutoScalePolicies []*AutoScalePolicy `json:"autoscalepolicy"` -} - -type AutoScalePolicy struct { - Account string `json:"account,omitempty"` - Action string `json:"action,omitempty"` - Conditions []string `json:"conditions,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Duration int `json:"duration,omitempty"` - Id string `json:"id,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Quiettime int `json:"quiettime,omitempty"` -} - -type ListAutoScaleVmProfilesParams struct { - p map[string]interface{} -} - -func (p *ListAutoScaleVmProfilesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["otherdeployparams"]; found { - u.Set("otherdeployparams", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["serviceofferingid"]; found { - u.Set("serviceofferingid", v.(string)) - } - if v, found := p.p["templateid"]; found { - u.Set("templateid", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ListAutoScaleVmProfilesParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListAutoScaleVmProfilesParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListAutoScaleVmProfilesParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *ListAutoScaleVmProfilesParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListAutoScaleVmProfilesParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListAutoScaleVmProfilesParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListAutoScaleVmProfilesParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListAutoScaleVmProfilesParams) SetOtherdeployparams(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["otherdeployparams"] = v - return -} - -func (p *ListAutoScaleVmProfilesParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListAutoScaleVmProfilesParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListAutoScaleVmProfilesParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListAutoScaleVmProfilesParams) SetServiceofferingid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["serviceofferingid"] = v - return -} - -func (p *ListAutoScaleVmProfilesParams) SetTemplateid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["templateid"] = v - return -} - -func (p *ListAutoScaleVmProfilesParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ListAutoScaleVmProfilesParams instance, -// as then you are sure you have configured all required params -func (s *AutoScaleService) NewListAutoScaleVmProfilesParams() *ListAutoScaleVmProfilesParams { - p := &ListAutoScaleVmProfilesParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *AutoScaleService) GetAutoScaleVmProfileByID(id string, opts ...OptionFunc) (*AutoScaleVmProfile, int, error) { - p := &ListAutoScaleVmProfilesParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListAutoScaleVmProfiles(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.AutoScaleVmProfiles[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for AutoScaleVmProfile UUID: %s!", id) -} - -// Lists autoscale vm profiles. -func (s *AutoScaleService) ListAutoScaleVmProfiles(p *ListAutoScaleVmProfilesParams) (*ListAutoScaleVmProfilesResponse, error) { - resp, err := s.cs.newRequest("listAutoScaleVmProfiles", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListAutoScaleVmProfilesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListAutoScaleVmProfilesResponse struct { - Count int `json:"count"` - AutoScaleVmProfiles []*AutoScaleVmProfile `json:"autoscalevmprofile"` -} - -type AutoScaleVmProfile struct { - Account string `json:"account,omitempty"` - Autoscaleuserid string `json:"autoscaleuserid,omitempty"` - Destroyvmgraceperiod int `json:"destroyvmgraceperiod,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Otherdeployparams string `json:"otherdeployparams,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Templateid string `json:"templateid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type ListAutoScaleVmGroupsParams struct { - p map[string]interface{} -} - -func (p *ListAutoScaleVmGroupsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["lbruleid"]; found { - u.Set("lbruleid", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["policyid"]; found { - u.Set("policyid", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["vmprofileid"]; found { - u.Set("vmprofileid", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ListAutoScaleVmGroupsParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListAutoScaleVmGroupsParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListAutoScaleVmGroupsParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *ListAutoScaleVmGroupsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListAutoScaleVmGroupsParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListAutoScaleVmGroupsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListAutoScaleVmGroupsParams) SetLbruleid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["lbruleid"] = v - return -} - -func (p *ListAutoScaleVmGroupsParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListAutoScaleVmGroupsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListAutoScaleVmGroupsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListAutoScaleVmGroupsParams) SetPolicyid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["policyid"] = v - return -} - -func (p *ListAutoScaleVmGroupsParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListAutoScaleVmGroupsParams) SetVmprofileid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vmprofileid"] = v - return -} - -func (p *ListAutoScaleVmGroupsParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ListAutoScaleVmGroupsParams instance, -// as then you are sure you have configured all required params -func (s *AutoScaleService) NewListAutoScaleVmGroupsParams() *ListAutoScaleVmGroupsParams { - p := &ListAutoScaleVmGroupsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *AutoScaleService) GetAutoScaleVmGroupByID(id string, opts ...OptionFunc) (*AutoScaleVmGroup, int, error) { - p := &ListAutoScaleVmGroupsParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListAutoScaleVmGroups(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.AutoScaleVmGroups[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for AutoScaleVmGroup UUID: %s!", id) -} - -// Lists autoscale vm groups. -func (s *AutoScaleService) ListAutoScaleVmGroups(p *ListAutoScaleVmGroupsParams) (*ListAutoScaleVmGroupsResponse, error) { - resp, err := s.cs.newRequest("listAutoScaleVmGroups", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListAutoScaleVmGroupsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListAutoScaleVmGroupsResponse struct { - Count int `json:"count"` - AutoScaleVmGroups []*AutoScaleVmGroup `json:"autoscalevmgroup"` -} - -type AutoScaleVmGroup struct { - Account string `json:"account,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Interval int `json:"interval,omitempty"` - Lbruleid string `json:"lbruleid,omitempty"` - Maxmembers int `json:"maxmembers,omitempty"` - Minmembers int `json:"minmembers,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Scaledownpolicies []string `json:"scaledownpolicies,omitempty"` - Scaleuppolicies []string `json:"scaleuppolicies,omitempty"` - State string `json:"state,omitempty"` - Vmprofileid string `json:"vmprofileid,omitempty"` -} - -type EnableAutoScaleVmGroupParams struct { - p map[string]interface{} -} - -func (p *EnableAutoScaleVmGroupParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *EnableAutoScaleVmGroupParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new EnableAutoScaleVmGroupParams instance, -// as then you are sure you have configured all required params -func (s *AutoScaleService) NewEnableAutoScaleVmGroupParams(id string) *EnableAutoScaleVmGroupParams { - p := &EnableAutoScaleVmGroupParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Enables an AutoScale Vm Group -func (s *AutoScaleService) EnableAutoScaleVmGroup(p *EnableAutoScaleVmGroupParams) (*EnableAutoScaleVmGroupResponse, error) { - resp, err := s.cs.newRequest("enableAutoScaleVmGroup", p.toURLValues()) - if err != nil { - return nil, err - } - - var r EnableAutoScaleVmGroupResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type EnableAutoScaleVmGroupResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Interval int `json:"interval,omitempty"` - Lbruleid string `json:"lbruleid,omitempty"` - Maxmembers int `json:"maxmembers,omitempty"` - Minmembers int `json:"minmembers,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Scaledownpolicies []string `json:"scaledownpolicies,omitempty"` - Scaleuppolicies []string `json:"scaleuppolicies,omitempty"` - State string `json:"state,omitempty"` - Vmprofileid string `json:"vmprofileid,omitempty"` -} - -type DisableAutoScaleVmGroupParams struct { - p map[string]interface{} -} - -func (p *DisableAutoScaleVmGroupParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DisableAutoScaleVmGroupParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DisableAutoScaleVmGroupParams instance, -// as then you are sure you have configured all required params -func (s *AutoScaleService) NewDisableAutoScaleVmGroupParams(id string) *DisableAutoScaleVmGroupParams { - p := &DisableAutoScaleVmGroupParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Disables an AutoScale Vm Group -func (s *AutoScaleService) DisableAutoScaleVmGroup(p *DisableAutoScaleVmGroupParams) (*DisableAutoScaleVmGroupResponse, error) { - resp, err := s.cs.newRequest("disableAutoScaleVmGroup", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DisableAutoScaleVmGroupResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DisableAutoScaleVmGroupResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Interval int `json:"interval,omitempty"` - Lbruleid string `json:"lbruleid,omitempty"` - Maxmembers int `json:"maxmembers,omitempty"` - Minmembers int `json:"minmembers,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Scaledownpolicies []string `json:"scaledownpolicies,omitempty"` - Scaleuppolicies []string `json:"scaleuppolicies,omitempty"` - State string `json:"state,omitempty"` - Vmprofileid string `json:"vmprofileid,omitempty"` -} - -type UpdateAutoScalePolicyParams struct { - p map[string]interface{} -} - -func (p *UpdateAutoScalePolicyParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["conditionids"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("conditionids", vv) - } - if v, found := p.p["duration"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("duration", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["quiettime"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("quiettime", vv) - } - return u -} - -func (p *UpdateAutoScalePolicyParams) SetConditionids(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["conditionids"] = v - return -} - -func (p *UpdateAutoScalePolicyParams) SetDuration(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["duration"] = v - return -} - -func (p *UpdateAutoScalePolicyParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateAutoScalePolicyParams) SetQuiettime(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["quiettime"] = v - return -} - -// You should always use this function to get a new UpdateAutoScalePolicyParams instance, -// as then you are sure you have configured all required params -func (s *AutoScaleService) NewUpdateAutoScalePolicyParams(id string) *UpdateAutoScalePolicyParams { - p := &UpdateAutoScalePolicyParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates an existing autoscale policy. -func (s *AutoScaleService) UpdateAutoScalePolicy(p *UpdateAutoScalePolicyParams) (*UpdateAutoScalePolicyResponse, error) { - resp, err := s.cs.newRequest("updateAutoScalePolicy", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateAutoScalePolicyResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateAutoScalePolicyResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Action string `json:"action,omitempty"` - Conditions []string `json:"conditions,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Duration int `json:"duration,omitempty"` - Id string `json:"id,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Quiettime int `json:"quiettime,omitempty"` -} - -type UpdateAutoScaleVmProfileParams struct { - p map[string]interface{} -} - -func (p *UpdateAutoScaleVmProfileParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["autoscaleuserid"]; found { - u.Set("autoscaleuserid", v.(string)) - } - if v, found := p.p["counterparam"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("counterparam[%d].key", i), k) - u.Set(fmt.Sprintf("counterparam[%d].value", i), vv) - i++ - } - } - if v, found := p.p["customid"]; found { - u.Set("customid", v.(string)) - } - if v, found := p.p["destroyvmgraceperiod"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("destroyvmgraceperiod", vv) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["templateid"]; found { - u.Set("templateid", v.(string)) - } - return u -} - -func (p *UpdateAutoScaleVmProfileParams) SetAutoscaleuserid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["autoscaleuserid"] = v - return -} - -func (p *UpdateAutoScaleVmProfileParams) SetCounterparam(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["counterparam"] = v - return -} - -func (p *UpdateAutoScaleVmProfileParams) SetCustomid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["customid"] = v - return -} - -func (p *UpdateAutoScaleVmProfileParams) SetDestroyvmgraceperiod(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["destroyvmgraceperiod"] = v - return -} - -func (p *UpdateAutoScaleVmProfileParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *UpdateAutoScaleVmProfileParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateAutoScaleVmProfileParams) SetTemplateid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["templateid"] = v - return -} - -// You should always use this function to get a new UpdateAutoScaleVmProfileParams instance, -// as then you are sure you have configured all required params -func (s *AutoScaleService) NewUpdateAutoScaleVmProfileParams(id string) *UpdateAutoScaleVmProfileParams { - p := &UpdateAutoScaleVmProfileParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates an existing autoscale vm profile. -func (s *AutoScaleService) UpdateAutoScaleVmProfile(p *UpdateAutoScaleVmProfileParams) (*UpdateAutoScaleVmProfileResponse, error) { - resp, err := s.cs.newRequest("updateAutoScaleVmProfile", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateAutoScaleVmProfileResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateAutoScaleVmProfileResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Autoscaleuserid string `json:"autoscaleuserid,omitempty"` - Destroyvmgraceperiod int `json:"destroyvmgraceperiod,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Otherdeployparams string `json:"otherdeployparams,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Templateid string `json:"templateid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type UpdateAutoScaleVmGroupParams struct { - p map[string]interface{} -} - -func (p *UpdateAutoScaleVmGroupParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["customid"]; found { - u.Set("customid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["interval"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("interval", vv) - } - if v, found := p.p["maxmembers"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("maxmembers", vv) - } - if v, found := p.p["minmembers"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("minmembers", vv) - } - if v, found := p.p["scaledownpolicyids"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("scaledownpolicyids", vv) - } - if v, found := p.p["scaleuppolicyids"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("scaleuppolicyids", vv) - } - return u -} - -func (p *UpdateAutoScaleVmGroupParams) SetCustomid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["customid"] = v - return -} - -func (p *UpdateAutoScaleVmGroupParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *UpdateAutoScaleVmGroupParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateAutoScaleVmGroupParams) SetInterval(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["interval"] = v - return -} - -func (p *UpdateAutoScaleVmGroupParams) SetMaxmembers(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["maxmembers"] = v - return -} - -func (p *UpdateAutoScaleVmGroupParams) SetMinmembers(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["minmembers"] = v - return -} - -func (p *UpdateAutoScaleVmGroupParams) SetScaledownpolicyids(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["scaledownpolicyids"] = v - return -} - -func (p *UpdateAutoScaleVmGroupParams) SetScaleuppolicyids(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["scaleuppolicyids"] = v - return -} - -// You should always use this function to get a new UpdateAutoScaleVmGroupParams instance, -// as then you are sure you have configured all required params -func (s *AutoScaleService) NewUpdateAutoScaleVmGroupParams(id string) *UpdateAutoScaleVmGroupParams { - p := &UpdateAutoScaleVmGroupParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates an existing autoscale vm group. -func (s *AutoScaleService) UpdateAutoScaleVmGroup(p *UpdateAutoScaleVmGroupParams) (*UpdateAutoScaleVmGroupResponse, error) { - resp, err := s.cs.newRequest("updateAutoScaleVmGroup", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateAutoScaleVmGroupResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateAutoScaleVmGroupResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Interval int `json:"interval,omitempty"` - Lbruleid string `json:"lbruleid,omitempty"` - Maxmembers int `json:"maxmembers,omitempty"` - Minmembers int `json:"minmembers,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Scaledownpolicies []string `json:"scaledownpolicies,omitempty"` - Scaleuppolicies []string `json:"scaleuppolicies,omitempty"` - State string `json:"state,omitempty"` - Vmprofileid string `json:"vmprofileid,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/BUILD b/vendor/github.com/xanzy/go-cloudstack/cloudstack/BUILD deleted file mode 100644 index 7da38320726..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/BUILD +++ /dev/null @@ -1,88 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -go_library( - name = "go_default_library", - srcs = [ - "APIDiscoveryService.go", - "AccountService.go", - "AddressService.go", - "AffinityGroupService.go", - "AlertService.go", - "AsyncjobService.go", - "AuthenticationService.go", - "AutoScaleService.go", - "BaremetalService.go", - "CertificateService.go", - "CloudIdentifierService.go", - "ClusterService.go", - "ConfigurationService.go", - "DiskOfferingService.go", - "DomainService.go", - "EventService.go", - "FirewallService.go", - "GuestOSService.go", - "HostService.go", - "HypervisorService.go", - "ISOService.go", - "ImageStoreService.go", - "InternalLBService.go", - "LDAPService.go", - "LimitService.go", - "LoadBalancerService.go", - "NATService.go", - "NetworkACLService.go", - "NetworkDeviceService.go", - "NetworkOfferingService.go", - "NetworkService.go", - "NicService.go", - "NiciraNVPService.go", - "OvsElementService.go", - "PodService.go", - "PoolService.go", - "PortableIPService.go", - "ProjectService.go", - "QuotaService.go", - "RegionService.go", - "ResourcemetadataService.go", - "ResourcetagsService.go", - "RouterService.go", - "SSHService.go", - "SecurityGroupService.go", - "ServiceOfferingService.go", - "SnapshotService.go", - "StoragePoolService.go", - "StratosphereSSPService.go", - "SwiftService.go", - "SystemCapacityService.go", - "SystemVMService.go", - "TemplateService.go", - "UCSService.go", - "UsageService.go", - "UserService.go", - "VLANService.go", - "VMGroupService.go", - "VPCService.go", - "VPNService.go", - "VirtualMachineService.go", - "VolumeService.go", - "ZoneService.go", - "cloudstack.go", - ], - importmap = "k8s.io/kubernetes/vendor/github.com/xanzy/go-cloudstack/cloudstack", - importpath = "github.com/xanzy/go-cloudstack/cloudstack", - visibility = ["//visibility:public"], -) - -filegroup( - name = "package-srcs", - srcs = glob(["**"]), - tags = ["automanaged"], - visibility = ["//visibility:private"], -) - -filegroup( - name = "all-srcs", - srcs = [":package-srcs"], - tags = ["automanaged"], - visibility = ["//visibility:public"], -) diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/BaremetalService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/BaremetalService.go deleted file mode 100644 index c1b7eaaba8f..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/BaremetalService.go +++ /dev/null @@ -1,918 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "net/url" - "strconv" -) - -type AddBaremetalPxeKickStartServerParams struct { - p map[string]interface{} -} - -func (p *AddBaremetalPxeKickStartServerParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["password"]; found { - u.Set("password", v.(string)) - } - if v, found := p.p["physicalnetworkid"]; found { - u.Set("physicalnetworkid", v.(string)) - } - if v, found := p.p["podid"]; found { - u.Set("podid", v.(string)) - } - if v, found := p.p["pxeservertype"]; found { - u.Set("pxeservertype", v.(string)) - } - if v, found := p.p["tftpdir"]; found { - u.Set("tftpdir", v.(string)) - } - if v, found := p.p["url"]; found { - u.Set("url", v.(string)) - } - if v, found := p.p["username"]; found { - u.Set("username", v.(string)) - } - return u -} - -func (p *AddBaremetalPxeKickStartServerParams) SetPassword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["password"] = v - return -} - -func (p *AddBaremetalPxeKickStartServerParams) SetPhysicalnetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["physicalnetworkid"] = v - return -} - -func (p *AddBaremetalPxeKickStartServerParams) SetPodid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["podid"] = v - return -} - -func (p *AddBaremetalPxeKickStartServerParams) SetPxeservertype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pxeservertype"] = v - return -} - -func (p *AddBaremetalPxeKickStartServerParams) SetTftpdir(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tftpdir"] = v - return -} - -func (p *AddBaremetalPxeKickStartServerParams) SetUrl(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["url"] = v - return -} - -func (p *AddBaremetalPxeKickStartServerParams) SetUsername(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["username"] = v - return -} - -// You should always use this function to get a new AddBaremetalPxeKickStartServerParams instance, -// as then you are sure you have configured all required params -func (s *BaremetalService) NewAddBaremetalPxeKickStartServerParams(password string, physicalnetworkid string, pxeservertype string, tftpdir string, url string, username string) *AddBaremetalPxeKickStartServerParams { - p := &AddBaremetalPxeKickStartServerParams{} - p.p = make(map[string]interface{}) - p.p["password"] = password - p.p["physicalnetworkid"] = physicalnetworkid - p.p["pxeservertype"] = pxeservertype - p.p["tftpdir"] = tftpdir - p.p["url"] = url - p.p["username"] = username - return p -} - -// add a baremetal pxe server -func (s *BaremetalService) AddBaremetalPxeKickStartServer(p *AddBaremetalPxeKickStartServerParams) (*AddBaremetalPxeKickStartServerResponse, error) { - resp, err := s.cs.newRequest("addBaremetalPxeKickStartServer", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AddBaremetalPxeKickStartServerResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type AddBaremetalPxeKickStartServerResponse struct { - JobID string `json:"jobid,omitempty"` - Tftpdir string `json:"tftpdir,omitempty"` -} - -type AddBaremetalPxePingServerParams struct { - p map[string]interface{} -} - -func (p *AddBaremetalPxePingServerParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["password"]; found { - u.Set("password", v.(string)) - } - if v, found := p.p["physicalnetworkid"]; found { - u.Set("physicalnetworkid", v.(string)) - } - if v, found := p.p["pingcifspassword"]; found { - u.Set("pingcifspassword", v.(string)) - } - if v, found := p.p["pingcifsusername"]; found { - u.Set("pingcifsusername", v.(string)) - } - if v, found := p.p["pingdir"]; found { - u.Set("pingdir", v.(string)) - } - if v, found := p.p["pingstorageserverip"]; found { - u.Set("pingstorageserverip", v.(string)) - } - if v, found := p.p["podid"]; found { - u.Set("podid", v.(string)) - } - if v, found := p.p["pxeservertype"]; found { - u.Set("pxeservertype", v.(string)) - } - if v, found := p.p["tftpdir"]; found { - u.Set("tftpdir", v.(string)) - } - if v, found := p.p["url"]; found { - u.Set("url", v.(string)) - } - if v, found := p.p["username"]; found { - u.Set("username", v.(string)) - } - return u -} - -func (p *AddBaremetalPxePingServerParams) SetPassword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["password"] = v - return -} - -func (p *AddBaremetalPxePingServerParams) SetPhysicalnetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["physicalnetworkid"] = v - return -} - -func (p *AddBaremetalPxePingServerParams) SetPingcifspassword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pingcifspassword"] = v - return -} - -func (p *AddBaremetalPxePingServerParams) SetPingcifsusername(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pingcifsusername"] = v - return -} - -func (p *AddBaremetalPxePingServerParams) SetPingdir(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pingdir"] = v - return -} - -func (p *AddBaremetalPxePingServerParams) SetPingstorageserverip(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pingstorageserverip"] = v - return -} - -func (p *AddBaremetalPxePingServerParams) SetPodid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["podid"] = v - return -} - -func (p *AddBaremetalPxePingServerParams) SetPxeservertype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pxeservertype"] = v - return -} - -func (p *AddBaremetalPxePingServerParams) SetTftpdir(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tftpdir"] = v - return -} - -func (p *AddBaremetalPxePingServerParams) SetUrl(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["url"] = v - return -} - -func (p *AddBaremetalPxePingServerParams) SetUsername(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["username"] = v - return -} - -// You should always use this function to get a new AddBaremetalPxePingServerParams instance, -// as then you are sure you have configured all required params -func (s *BaremetalService) NewAddBaremetalPxePingServerParams(password string, physicalnetworkid string, pingdir string, pingstorageserverip string, pxeservertype string, tftpdir string, url string, username string) *AddBaremetalPxePingServerParams { - p := &AddBaremetalPxePingServerParams{} - p.p = make(map[string]interface{}) - p.p["password"] = password - p.p["physicalnetworkid"] = physicalnetworkid - p.p["pingdir"] = pingdir - p.p["pingstorageserverip"] = pingstorageserverip - p.p["pxeservertype"] = pxeservertype - p.p["tftpdir"] = tftpdir - p.p["url"] = url - p.p["username"] = username - return p -} - -// add a baremetal ping pxe server -func (s *BaremetalService) AddBaremetalPxePingServer(p *AddBaremetalPxePingServerParams) (*AddBaremetalPxePingServerResponse, error) { - resp, err := s.cs.newRequest("addBaremetalPxePingServer", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AddBaremetalPxePingServerResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type AddBaremetalPxePingServerResponse struct { - JobID string `json:"jobid,omitempty"` - Pingdir string `json:"pingdir,omitempty"` - Pingstorageserverip string `json:"pingstorageserverip,omitempty"` - Tftpdir string `json:"tftpdir,omitempty"` -} - -type AddBaremetalDhcpParams struct { - p map[string]interface{} -} - -func (p *AddBaremetalDhcpParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["dhcpservertype"]; found { - u.Set("dhcpservertype", v.(string)) - } - if v, found := p.p["password"]; found { - u.Set("password", v.(string)) - } - if v, found := p.p["physicalnetworkid"]; found { - u.Set("physicalnetworkid", v.(string)) - } - if v, found := p.p["url"]; found { - u.Set("url", v.(string)) - } - if v, found := p.p["username"]; found { - u.Set("username", v.(string)) - } - return u -} - -func (p *AddBaremetalDhcpParams) SetDhcpservertype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["dhcpservertype"] = v - return -} - -func (p *AddBaremetalDhcpParams) SetPassword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["password"] = v - return -} - -func (p *AddBaremetalDhcpParams) SetPhysicalnetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["physicalnetworkid"] = v - return -} - -func (p *AddBaremetalDhcpParams) SetUrl(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["url"] = v - return -} - -func (p *AddBaremetalDhcpParams) SetUsername(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["username"] = v - return -} - -// You should always use this function to get a new AddBaremetalDhcpParams instance, -// as then you are sure you have configured all required params -func (s *BaremetalService) NewAddBaremetalDhcpParams(dhcpservertype string, password string, physicalnetworkid string, url string, username string) *AddBaremetalDhcpParams { - p := &AddBaremetalDhcpParams{} - p.p = make(map[string]interface{}) - p.p["dhcpservertype"] = dhcpservertype - p.p["password"] = password - p.p["physicalnetworkid"] = physicalnetworkid - p.p["url"] = url - p.p["username"] = username - return p -} - -// adds a baremetal dhcp server -func (s *BaremetalService) AddBaremetalDhcp(p *AddBaremetalDhcpParams) (*AddBaremetalDhcpResponse, error) { - resp, err := s.cs.newRequest("addBaremetalDhcp", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AddBaremetalDhcpResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type AddBaremetalDhcpResponse struct { - JobID string `json:"jobid,omitempty"` - Dhcpservertype string `json:"dhcpservertype,omitempty"` - Id string `json:"id,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Provider string `json:"provider,omitempty"` - Url string `json:"url,omitempty"` -} - -type ListBaremetalDhcpParams struct { - p map[string]interface{} -} - -func (p *ListBaremetalDhcpParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["dhcpservertype"]; found { - u.Set("dhcpservertype", v.(string)) - } - if v, found := p.p["id"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("id", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["physicalnetworkid"]; found { - u.Set("physicalnetworkid", v.(string)) - } - return u -} - -func (p *ListBaremetalDhcpParams) SetDhcpservertype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["dhcpservertype"] = v - return -} - -func (p *ListBaremetalDhcpParams) SetId(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListBaremetalDhcpParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListBaremetalDhcpParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListBaremetalDhcpParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListBaremetalDhcpParams) SetPhysicalnetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["physicalnetworkid"] = v - return -} - -// You should always use this function to get a new ListBaremetalDhcpParams instance, -// as then you are sure you have configured all required params -func (s *BaremetalService) NewListBaremetalDhcpParams(physicalnetworkid string) *ListBaremetalDhcpParams { - p := &ListBaremetalDhcpParams{} - p.p = make(map[string]interface{}) - p.p["physicalnetworkid"] = physicalnetworkid - return p -} - -// list baremetal dhcp servers -func (s *BaremetalService) ListBaremetalDhcp(p *ListBaremetalDhcpParams) (*ListBaremetalDhcpResponse, error) { - resp, err := s.cs.newRequest("listBaremetalDhcp", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListBaremetalDhcpResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListBaremetalDhcpResponse struct { - Count int `json:"count"` - BaremetalDhcp []*BaremetalDhcp `json:"baremetaldhcp"` -} - -type BaremetalDhcp struct { - Dhcpservertype string `json:"dhcpservertype,omitempty"` - Id string `json:"id,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Provider string `json:"provider,omitempty"` - Url string `json:"url,omitempty"` -} - -type ListBaremetalPxeServersParams struct { - p map[string]interface{} -} - -func (p *ListBaremetalPxeServersParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("id", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["physicalnetworkid"]; found { - u.Set("physicalnetworkid", v.(string)) - } - return u -} - -func (p *ListBaremetalPxeServersParams) SetId(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListBaremetalPxeServersParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListBaremetalPxeServersParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListBaremetalPxeServersParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListBaremetalPxeServersParams) SetPhysicalnetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["physicalnetworkid"] = v - return -} - -// You should always use this function to get a new ListBaremetalPxeServersParams instance, -// as then you are sure you have configured all required params -func (s *BaremetalService) NewListBaremetalPxeServersParams(physicalnetworkid string) *ListBaremetalPxeServersParams { - p := &ListBaremetalPxeServersParams{} - p.p = make(map[string]interface{}) - p.p["physicalnetworkid"] = physicalnetworkid - return p -} - -// list baremetal pxe server -func (s *BaremetalService) ListBaremetalPxeServers(p *ListBaremetalPxeServersParams) (*ListBaremetalPxeServersResponse, error) { - resp, err := s.cs.newRequest("listBaremetalPxeServers", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListBaremetalPxeServersResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListBaremetalPxeServersResponse struct { - Count int `json:"count"` - BaremetalPxeServers []*BaremetalPxeServer `json:"baremetalpxeserver"` -} - -type BaremetalPxeServer struct { - Id string `json:"id,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Provider string `json:"provider,omitempty"` - Url string `json:"url,omitempty"` -} - -type AddBaremetalRctParams struct { - p map[string]interface{} -} - -func (p *AddBaremetalRctParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["baremetalrcturl"]; found { - u.Set("baremetalrcturl", v.(string)) - } - return u -} - -func (p *AddBaremetalRctParams) SetBaremetalrcturl(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["baremetalrcturl"] = v - return -} - -// You should always use this function to get a new AddBaremetalRctParams instance, -// as then you are sure you have configured all required params -func (s *BaremetalService) NewAddBaremetalRctParams(baremetalrcturl string) *AddBaremetalRctParams { - p := &AddBaremetalRctParams{} - p.p = make(map[string]interface{}) - p.p["baremetalrcturl"] = baremetalrcturl - return p -} - -// adds baremetal rack configuration text -func (s *BaremetalService) AddBaremetalRct(p *AddBaremetalRctParams) (*AddBaremetalRctResponse, error) { - resp, err := s.cs.newRequest("addBaremetalRct", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AddBaremetalRctResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type AddBaremetalRctResponse struct { - JobID string `json:"jobid,omitempty"` - Id string `json:"id,omitempty"` - Url string `json:"url,omitempty"` -} - -type DeleteBaremetalRctParams struct { - p map[string]interface{} -} - -func (p *DeleteBaremetalRctParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteBaremetalRctParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteBaremetalRctParams instance, -// as then you are sure you have configured all required params -func (s *BaremetalService) NewDeleteBaremetalRctParams(id string) *DeleteBaremetalRctParams { - p := &DeleteBaremetalRctParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// deletes baremetal rack configuration text -func (s *BaremetalService) DeleteBaremetalRct(p *DeleteBaremetalRctParams) (*DeleteBaremetalRctResponse, error) { - resp, err := s.cs.newRequest("deleteBaremetalRct", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteBaremetalRctResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteBaremetalRctResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListBaremetalRctParams struct { - p map[string]interface{} -} - -func (p *ListBaremetalRctParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - return u -} - -func (p *ListBaremetalRctParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListBaremetalRctParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListBaremetalRctParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -// You should always use this function to get a new ListBaremetalRctParams instance, -// as then you are sure you have configured all required params -func (s *BaremetalService) NewListBaremetalRctParams() *ListBaremetalRctParams { - p := &ListBaremetalRctParams{} - p.p = make(map[string]interface{}) - return p -} - -// list baremetal rack configuration -func (s *BaremetalService) ListBaremetalRct(p *ListBaremetalRctParams) (*ListBaremetalRctResponse, error) { - resp, err := s.cs.newRequest("listBaremetalRct", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListBaremetalRctResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListBaremetalRctResponse struct { - Count int `json:"count"` - BaremetalRct []*BaremetalRct `json:"baremetalrct"` -} - -type BaremetalRct struct { - Id string `json:"id,omitempty"` - Url string `json:"url,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/CertificateService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/CertificateService.go deleted file mode 100644 index a13fcdfc21a..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/CertificateService.go +++ /dev/null @@ -1,140 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "net/url" - "strconv" -) - -type UploadCustomCertificateParams struct { - p map[string]interface{} -} - -func (p *UploadCustomCertificateParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["certificate"]; found { - u.Set("certificate", v.(string)) - } - if v, found := p.p["domainsuffix"]; found { - u.Set("domainsuffix", v.(string)) - } - if v, found := p.p["id"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("id", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["privatekey"]; found { - u.Set("privatekey", v.(string)) - } - return u -} - -func (p *UploadCustomCertificateParams) SetCertificate(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["certificate"] = v - return -} - -func (p *UploadCustomCertificateParams) SetDomainsuffix(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainsuffix"] = v - return -} - -func (p *UploadCustomCertificateParams) SetId(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UploadCustomCertificateParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *UploadCustomCertificateParams) SetPrivatekey(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["privatekey"] = v - return -} - -// You should always use this function to get a new UploadCustomCertificateParams instance, -// as then you are sure you have configured all required params -func (s *CertificateService) NewUploadCustomCertificateParams(certificate string, domainsuffix string) *UploadCustomCertificateParams { - p := &UploadCustomCertificateParams{} - p.p = make(map[string]interface{}) - p.p["certificate"] = certificate - p.p["domainsuffix"] = domainsuffix - return p -} - -// Uploads a custom certificate for the console proxy VMs to use for SSL. Can be used to upload a single certificate signed by a known CA. Can also be used, through multiple calls, to upload a chain of certificates from CA to the custom certificate itself. -func (s *CertificateService) UploadCustomCertificate(p *UploadCustomCertificateParams) (*UploadCustomCertificateResponse, error) { - resp, err := s.cs.newRequest("uploadCustomCertificate", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UploadCustomCertificateResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UploadCustomCertificateResponse struct { - JobID string `json:"jobid,omitempty"` - Message string `json:"message,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/CloudIdentifierService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/CloudIdentifierService.go deleted file mode 100644 index 99eeba2c8ec..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/CloudIdentifierService.go +++ /dev/null @@ -1,74 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "net/url" -) - -type GetCloudIdentifierParams struct { - p map[string]interface{} -} - -func (p *GetCloudIdentifierParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["userid"]; found { - u.Set("userid", v.(string)) - } - return u -} - -func (p *GetCloudIdentifierParams) SetUserid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["userid"] = v - return -} - -// You should always use this function to get a new GetCloudIdentifierParams instance, -// as then you are sure you have configured all required params -func (s *CloudIdentifierService) NewGetCloudIdentifierParams(userid string) *GetCloudIdentifierParams { - p := &GetCloudIdentifierParams{} - p.p = make(map[string]interface{}) - p.p["userid"] = userid - return p -} - -// Retrieves a cloud identifier. -func (s *CloudIdentifierService) GetCloudIdentifier(p *GetCloudIdentifierParams) (*GetCloudIdentifierResponse, error) { - resp, err := s.cs.newRequest("getCloudIdentifier", p.toURLValues()) - if err != nil { - return nil, err - } - - var r GetCloudIdentifierResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type GetCloudIdentifierResponse struct { - Cloudidentifier string `json:"cloudidentifier,omitempty"` - Signature string `json:"signature,omitempty"` - Userid string `json:"userid,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/ClusterService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/ClusterService.go deleted file mode 100644 index 0ba05b4d96d..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/ClusterService.go +++ /dev/null @@ -1,1059 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type AddClusterParams struct { - p map[string]interface{} -} - -func (p *AddClusterParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["allocationstate"]; found { - u.Set("allocationstate", v.(string)) - } - if v, found := p.p["clustername"]; found { - u.Set("clustername", v.(string)) - } - if v, found := p.p["clustertype"]; found { - u.Set("clustertype", v.(string)) - } - if v, found := p.p["guestvswitchname"]; found { - u.Set("guestvswitchname", v.(string)) - } - if v, found := p.p["guestvswitchtype"]; found { - u.Set("guestvswitchtype", v.(string)) - } - if v, found := p.p["hypervisor"]; found { - u.Set("hypervisor", v.(string)) - } - if v, found := p.p["ovm3cluster"]; found { - u.Set("ovm3cluster", v.(string)) - } - if v, found := p.p["ovm3pool"]; found { - u.Set("ovm3pool", v.(string)) - } - if v, found := p.p["ovm3vip"]; found { - u.Set("ovm3vip", v.(string)) - } - if v, found := p.p["password"]; found { - u.Set("password", v.(string)) - } - if v, found := p.p["podid"]; found { - u.Set("podid", v.(string)) - } - if v, found := p.p["publicvswitchname"]; found { - u.Set("publicvswitchname", v.(string)) - } - if v, found := p.p["publicvswitchtype"]; found { - u.Set("publicvswitchtype", v.(string)) - } - if v, found := p.p["url"]; found { - u.Set("url", v.(string)) - } - if v, found := p.p["username"]; found { - u.Set("username", v.(string)) - } - if v, found := p.p["vsmipaddress"]; found { - u.Set("vsmipaddress", v.(string)) - } - if v, found := p.p["vsmpassword"]; found { - u.Set("vsmpassword", v.(string)) - } - if v, found := p.p["vsmusername"]; found { - u.Set("vsmusername", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *AddClusterParams) SetAllocationstate(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["allocationstate"] = v - return -} - -func (p *AddClusterParams) SetClustername(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["clustername"] = v - return -} - -func (p *AddClusterParams) SetClustertype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["clustertype"] = v - return -} - -func (p *AddClusterParams) SetGuestvswitchname(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["guestvswitchname"] = v - return -} - -func (p *AddClusterParams) SetGuestvswitchtype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["guestvswitchtype"] = v - return -} - -func (p *AddClusterParams) SetHypervisor(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hypervisor"] = v - return -} - -func (p *AddClusterParams) SetOvm3cluster(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ovm3cluster"] = v - return -} - -func (p *AddClusterParams) SetOvm3pool(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ovm3pool"] = v - return -} - -func (p *AddClusterParams) SetOvm3vip(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ovm3vip"] = v - return -} - -func (p *AddClusterParams) SetPassword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["password"] = v - return -} - -func (p *AddClusterParams) SetPodid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["podid"] = v - return -} - -func (p *AddClusterParams) SetPublicvswitchname(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["publicvswitchname"] = v - return -} - -func (p *AddClusterParams) SetPublicvswitchtype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["publicvswitchtype"] = v - return -} - -func (p *AddClusterParams) SetUrl(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["url"] = v - return -} - -func (p *AddClusterParams) SetUsername(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["username"] = v - return -} - -func (p *AddClusterParams) SetVsmipaddress(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vsmipaddress"] = v - return -} - -func (p *AddClusterParams) SetVsmpassword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vsmpassword"] = v - return -} - -func (p *AddClusterParams) SetVsmusername(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vsmusername"] = v - return -} - -func (p *AddClusterParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new AddClusterParams instance, -// as then you are sure you have configured all required params -func (s *ClusterService) NewAddClusterParams(clustername string, clustertype string, hypervisor string, podid string, zoneid string) *AddClusterParams { - p := &AddClusterParams{} - p.p = make(map[string]interface{}) - p.p["clustername"] = clustername - p.p["clustertype"] = clustertype - p.p["hypervisor"] = hypervisor - p.p["podid"] = podid - p.p["zoneid"] = zoneid - return p -} - -// Adds a new cluster -func (s *ClusterService) AddCluster(p *AddClusterParams) (*AddClusterResponse, error) { - resp, err := s.cs.newRequest("addCluster", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AddClusterResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type AddClusterResponse struct { - Allocationstate string `json:"allocationstate,omitempty"` - Capacity []struct { - Capacitytotal int64 `json:"capacitytotal,omitempty"` - Capacityused int64 `json:"capacityused,omitempty"` - Clusterid string `json:"clusterid,omitempty"` - Clustername string `json:"clustername,omitempty"` - Percentused string `json:"percentused,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` - Type int `json:"type,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` - } `json:"capacity,omitempty"` - Clustertype string `json:"clustertype,omitempty"` - Cpuovercommitratio string `json:"cpuovercommitratio,omitempty"` - Hypervisortype string `json:"hypervisortype,omitempty"` - Id string `json:"id,omitempty"` - Managedstate string `json:"managedstate,omitempty"` - Memoryovercommitratio string `json:"memoryovercommitratio,omitempty"` - Name string `json:"name,omitempty"` - Ovm3vip string `json:"ovm3vip,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type DeleteClusterParams struct { - p map[string]interface{} -} - -func (p *DeleteClusterParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteClusterParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteClusterParams instance, -// as then you are sure you have configured all required params -func (s *ClusterService) NewDeleteClusterParams(id string) *DeleteClusterParams { - p := &DeleteClusterParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a cluster. -func (s *ClusterService) DeleteCluster(p *DeleteClusterParams) (*DeleteClusterResponse, error) { - resp, err := s.cs.newRequest("deleteCluster", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteClusterResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type DeleteClusterResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} - -type UpdateClusterParams struct { - p map[string]interface{} -} - -func (p *UpdateClusterParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["allocationstate"]; found { - u.Set("allocationstate", v.(string)) - } - if v, found := p.p["clustername"]; found { - u.Set("clustername", v.(string)) - } - if v, found := p.p["clustertype"]; found { - u.Set("clustertype", v.(string)) - } - if v, found := p.p["hypervisor"]; found { - u.Set("hypervisor", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["managedstate"]; found { - u.Set("managedstate", v.(string)) - } - return u -} - -func (p *UpdateClusterParams) SetAllocationstate(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["allocationstate"] = v - return -} - -func (p *UpdateClusterParams) SetClustername(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["clustername"] = v - return -} - -func (p *UpdateClusterParams) SetClustertype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["clustertype"] = v - return -} - -func (p *UpdateClusterParams) SetHypervisor(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hypervisor"] = v - return -} - -func (p *UpdateClusterParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateClusterParams) SetManagedstate(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["managedstate"] = v - return -} - -// You should always use this function to get a new UpdateClusterParams instance, -// as then you are sure you have configured all required params -func (s *ClusterService) NewUpdateClusterParams(id string) *UpdateClusterParams { - p := &UpdateClusterParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates an existing cluster -func (s *ClusterService) UpdateCluster(p *UpdateClusterParams) (*UpdateClusterResponse, error) { - resp, err := s.cs.newRequest("updateCluster", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateClusterResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type UpdateClusterResponse struct { - Allocationstate string `json:"allocationstate,omitempty"` - Capacity []struct { - Capacitytotal int64 `json:"capacitytotal,omitempty"` - Capacityused int64 `json:"capacityused,omitempty"` - Clusterid string `json:"clusterid,omitempty"` - Clustername string `json:"clustername,omitempty"` - Percentused string `json:"percentused,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` - Type int `json:"type,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` - } `json:"capacity,omitempty"` - Clustertype string `json:"clustertype,omitempty"` - Cpuovercommitratio string `json:"cpuovercommitratio,omitempty"` - Hypervisortype string `json:"hypervisortype,omitempty"` - Id string `json:"id,omitempty"` - Managedstate string `json:"managedstate,omitempty"` - Memoryovercommitratio string `json:"memoryovercommitratio,omitempty"` - Name string `json:"name,omitempty"` - Ovm3vip string `json:"ovm3vip,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type ListClustersParams struct { - p map[string]interface{} -} - -func (p *ListClustersParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["allocationstate"]; found { - u.Set("allocationstate", v.(string)) - } - if v, found := p.p["clustertype"]; found { - u.Set("clustertype", v.(string)) - } - if v, found := p.p["hypervisor"]; found { - u.Set("hypervisor", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["managedstate"]; found { - u.Set("managedstate", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["podid"]; found { - u.Set("podid", v.(string)) - } - if v, found := p.p["showcapacities"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("showcapacities", vv) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ListClustersParams) SetAllocationstate(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["allocationstate"] = v - return -} - -func (p *ListClustersParams) SetClustertype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["clustertype"] = v - return -} - -func (p *ListClustersParams) SetHypervisor(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hypervisor"] = v - return -} - -func (p *ListClustersParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListClustersParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListClustersParams) SetManagedstate(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["managedstate"] = v - return -} - -func (p *ListClustersParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListClustersParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListClustersParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListClustersParams) SetPodid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["podid"] = v - return -} - -func (p *ListClustersParams) SetShowcapacities(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["showcapacities"] = v - return -} - -func (p *ListClustersParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ListClustersParams instance, -// as then you are sure you have configured all required params -func (s *ClusterService) NewListClustersParams() *ListClustersParams { - p := &ListClustersParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *ClusterService) GetClusterID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListClustersParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListClusters(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.Clusters[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.Clusters { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *ClusterService) GetClusterByName(name string, opts ...OptionFunc) (*Cluster, int, error) { - id, count, err := s.GetClusterID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetClusterByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *ClusterService) GetClusterByID(id string, opts ...OptionFunc) (*Cluster, int, error) { - p := &ListClustersParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListClusters(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.Clusters[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for Cluster UUID: %s!", id) -} - -// Lists clusters. -func (s *ClusterService) ListClusters(p *ListClustersParams) (*ListClustersResponse, error) { - resp, err := s.cs.newRequest("listClusters", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListClustersResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListClustersResponse struct { - Count int `json:"count"` - Clusters []*Cluster `json:"cluster"` -} - -type Cluster struct { - Allocationstate string `json:"allocationstate,omitempty"` - Capacity []struct { - Capacitytotal int64 `json:"capacitytotal,omitempty"` - Capacityused int64 `json:"capacityused,omitempty"` - Clusterid string `json:"clusterid,omitempty"` - Clustername string `json:"clustername,omitempty"` - Percentused string `json:"percentused,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` - Type int `json:"type,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` - } `json:"capacity,omitempty"` - Clustertype string `json:"clustertype,omitempty"` - Cpuovercommitratio string `json:"cpuovercommitratio,omitempty"` - Hypervisortype string `json:"hypervisortype,omitempty"` - Id string `json:"id,omitempty"` - Managedstate string `json:"managedstate,omitempty"` - Memoryovercommitratio string `json:"memoryovercommitratio,omitempty"` - Name string `json:"name,omitempty"` - Ovm3vip string `json:"ovm3vip,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type DedicateClusterParams struct { - p map[string]interface{} -} - -func (p *DedicateClusterParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["clusterid"]; found { - u.Set("clusterid", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - return u -} - -func (p *DedicateClusterParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *DedicateClusterParams) SetClusterid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["clusterid"] = v - return -} - -func (p *DedicateClusterParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -// You should always use this function to get a new DedicateClusterParams instance, -// as then you are sure you have configured all required params -func (s *ClusterService) NewDedicateClusterParams(clusterid string, domainid string) *DedicateClusterParams { - p := &DedicateClusterParams{} - p.p = make(map[string]interface{}) - p.p["clusterid"] = clusterid - p.p["domainid"] = domainid - return p -} - -// Dedicate an existing cluster -func (s *ClusterService) DedicateCluster(p *DedicateClusterParams) (*DedicateClusterResponse, error) { - resp, err := s.cs.newRequest("dedicateCluster", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DedicateClusterResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DedicateClusterResponse struct { - JobID string `json:"jobid,omitempty"` - Accountid string `json:"accountid,omitempty"` - Affinitygroupid string `json:"affinitygroupid,omitempty"` - Clusterid string `json:"clusterid,omitempty"` - Clustername string `json:"clustername,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` -} - -type ReleaseDedicatedClusterParams struct { - p map[string]interface{} -} - -func (p *ReleaseDedicatedClusterParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["clusterid"]; found { - u.Set("clusterid", v.(string)) - } - return u -} - -func (p *ReleaseDedicatedClusterParams) SetClusterid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["clusterid"] = v - return -} - -// You should always use this function to get a new ReleaseDedicatedClusterParams instance, -// as then you are sure you have configured all required params -func (s *ClusterService) NewReleaseDedicatedClusterParams(clusterid string) *ReleaseDedicatedClusterParams { - p := &ReleaseDedicatedClusterParams{} - p.p = make(map[string]interface{}) - p.p["clusterid"] = clusterid - return p -} - -// Release the dedication for cluster -func (s *ClusterService) ReleaseDedicatedCluster(p *ReleaseDedicatedClusterParams) (*ReleaseDedicatedClusterResponse, error) { - resp, err := s.cs.newRequest("releaseDedicatedCluster", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ReleaseDedicatedClusterResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type ReleaseDedicatedClusterResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListDedicatedClustersParams struct { - p map[string]interface{} -} - -func (p *ListDedicatedClustersParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["affinitygroupid"]; found { - u.Set("affinitygroupid", v.(string)) - } - if v, found := p.p["clusterid"]; found { - u.Set("clusterid", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - return u -} - -func (p *ListDedicatedClustersParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListDedicatedClustersParams) SetAffinitygroupid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["affinitygroupid"] = v - return -} - -func (p *ListDedicatedClustersParams) SetClusterid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["clusterid"] = v - return -} - -func (p *ListDedicatedClustersParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListDedicatedClustersParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListDedicatedClustersParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListDedicatedClustersParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -// You should always use this function to get a new ListDedicatedClustersParams instance, -// as then you are sure you have configured all required params -func (s *ClusterService) NewListDedicatedClustersParams() *ListDedicatedClustersParams { - p := &ListDedicatedClustersParams{} - p.p = make(map[string]interface{}) - return p -} - -// Lists dedicated clusters. -func (s *ClusterService) ListDedicatedClusters(p *ListDedicatedClustersParams) (*ListDedicatedClustersResponse, error) { - resp, err := s.cs.newRequest("listDedicatedClusters", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListDedicatedClustersResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListDedicatedClustersResponse struct { - Count int `json:"count"` - DedicatedClusters []*DedicatedCluster `json:"dedicatedcluster"` -} - -type DedicatedCluster struct { - Accountid string `json:"accountid,omitempty"` - Affinitygroupid string `json:"affinitygroupid,omitempty"` - Clusterid string `json:"clusterid,omitempty"` - Clustername string `json:"clustername,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/ConfigurationService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/ConfigurationService.go deleted file mode 100644 index b4a6a7b1bfd..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/ConfigurationService.go +++ /dev/null @@ -1,633 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "net/url" - "strconv" -) - -type UpdateConfigurationParams struct { - p map[string]interface{} -} - -func (p *UpdateConfigurationParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["accountid"]; found { - u.Set("accountid", v.(string)) - } - if v, found := p.p["clusterid"]; found { - u.Set("clusterid", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["storageid"]; found { - u.Set("storageid", v.(string)) - } - if v, found := p.p["value"]; found { - u.Set("value", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *UpdateConfigurationParams) SetAccountid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["accountid"] = v - return -} - -func (p *UpdateConfigurationParams) SetClusterid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["clusterid"] = v - return -} - -func (p *UpdateConfigurationParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *UpdateConfigurationParams) SetStorageid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["storageid"] = v - return -} - -func (p *UpdateConfigurationParams) SetValue(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["value"] = v - return -} - -func (p *UpdateConfigurationParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new UpdateConfigurationParams instance, -// as then you are sure you have configured all required params -func (s *ConfigurationService) NewUpdateConfigurationParams(name string) *UpdateConfigurationParams { - p := &UpdateConfigurationParams{} - p.p = make(map[string]interface{}) - p.p["name"] = name - return p -} - -// Updates a configuration. -func (s *ConfigurationService) UpdateConfiguration(p *UpdateConfigurationParams) (*UpdateConfigurationResponse, error) { - resp, err := s.cs.newRequest("updateConfiguration", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateConfigurationResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type UpdateConfigurationResponse struct { - Category string `json:"category,omitempty"` - Description string `json:"description,omitempty"` - Id int64 `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Scope string `json:"scope,omitempty"` - Value string `json:"value,omitempty"` -} - -type ListConfigurationsParams struct { - p map[string]interface{} -} - -func (p *ListConfigurationsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["accountid"]; found { - u.Set("accountid", v.(string)) - } - if v, found := p.p["category"]; found { - u.Set("category", v.(string)) - } - if v, found := p.p["clusterid"]; found { - u.Set("clusterid", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["storageid"]; found { - u.Set("storageid", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ListConfigurationsParams) SetAccountid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["accountid"] = v - return -} - -func (p *ListConfigurationsParams) SetCategory(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["category"] = v - return -} - -func (p *ListConfigurationsParams) SetClusterid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["clusterid"] = v - return -} - -func (p *ListConfigurationsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListConfigurationsParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListConfigurationsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListConfigurationsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListConfigurationsParams) SetStorageid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["storageid"] = v - return -} - -func (p *ListConfigurationsParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ListConfigurationsParams instance, -// as then you are sure you have configured all required params -func (s *ConfigurationService) NewListConfigurationsParams() *ListConfigurationsParams { - p := &ListConfigurationsParams{} - p.p = make(map[string]interface{}) - return p -} - -// Lists all configurations. -func (s *ConfigurationService) ListConfigurations(p *ListConfigurationsParams) (*ListConfigurationsResponse, error) { - resp, err := s.cs.newRequest("listConfigurations", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListConfigurationsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListConfigurationsResponse struct { - Count int `json:"count"` - Configurations []*Configuration `json:"configuration"` -} - -type Configuration struct { - Category string `json:"category,omitempty"` - Description string `json:"description,omitempty"` - Id int64 `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Scope string `json:"scope,omitempty"` - Value string `json:"value,omitempty"` -} - -type ListCapabilitiesParams struct { - p map[string]interface{} -} - -func (p *ListCapabilitiesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - return u -} - -// You should always use this function to get a new ListCapabilitiesParams instance, -// as then you are sure you have configured all required params -func (s *ConfigurationService) NewListCapabilitiesParams() *ListCapabilitiesParams { - p := &ListCapabilitiesParams{} - p.p = make(map[string]interface{}) - return p -} - -// Lists capabilities -func (s *ConfigurationService) ListCapabilities(p *ListCapabilitiesParams) (*ListCapabilitiesResponse, error) { - resp, err := s.cs.newRequest("listCapabilities", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListCapabilitiesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListCapabilitiesResponse struct { - Count int `json:"count"` - Capabilities []*Capability `json:"capability"` -} - -type Capability struct { - Allowusercreateprojects bool `json:"allowusercreateprojects,omitempty"` - Allowuserexpungerecovervm bool `json:"allowuserexpungerecovervm,omitempty"` - Allowuserviewdestroyedvm bool `json:"allowuserviewdestroyedvm,omitempty"` - Apilimitinterval int `json:"apilimitinterval,omitempty"` - Apilimitmax int `json:"apilimitmax,omitempty"` - Cloudstackversion string `json:"cloudstackversion,omitempty"` - Customdiskofferingmaxsize int64 `json:"customdiskofferingmaxsize,omitempty"` - Customdiskofferingminsize int64 `json:"customdiskofferingminsize,omitempty"` - Kvmsnapshotenabled bool `json:"kvmsnapshotenabled,omitempty"` - Projectinviterequired bool `json:"projectinviterequired,omitempty"` - Regionsecondaryenabled bool `json:"regionsecondaryenabled,omitempty"` - Securitygroupsenabled bool `json:"securitygroupsenabled,omitempty"` - SupportELB string `json:"supportELB,omitempty"` - Userpublictemplateenabled bool `json:"userpublictemplateenabled,omitempty"` -} - -type ListDeploymentPlannersParams struct { - p map[string]interface{} -} - -func (p *ListDeploymentPlannersParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - return u -} - -func (p *ListDeploymentPlannersParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListDeploymentPlannersParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListDeploymentPlannersParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -// You should always use this function to get a new ListDeploymentPlannersParams instance, -// as then you are sure you have configured all required params -func (s *ConfigurationService) NewListDeploymentPlannersParams() *ListDeploymentPlannersParams { - p := &ListDeploymentPlannersParams{} - p.p = make(map[string]interface{}) - return p -} - -// Lists all DeploymentPlanners available. -func (s *ConfigurationService) ListDeploymentPlanners(p *ListDeploymentPlannersParams) (*ListDeploymentPlannersResponse, error) { - resp, err := s.cs.newRequest("listDeploymentPlanners", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListDeploymentPlannersResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListDeploymentPlannersResponse struct { - Count int `json:"count"` - DeploymentPlanners []*DeploymentPlanner `json:"deploymentplanner"` -} - -type DeploymentPlanner struct { - Name string `json:"name,omitempty"` -} - -type ListLdapConfigurationsParams struct { - p map[string]interface{} -} - -func (p *ListLdapConfigurationsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["hostname"]; found { - u.Set("hostname", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["port"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("port", vv) - } - return u -} - -func (p *ListLdapConfigurationsParams) SetHostname(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hostname"] = v - return -} - -func (p *ListLdapConfigurationsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListLdapConfigurationsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListLdapConfigurationsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListLdapConfigurationsParams) SetPort(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["port"] = v - return -} - -// You should always use this function to get a new ListLdapConfigurationsParams instance, -// as then you are sure you have configured all required params -func (s *ConfigurationService) NewListLdapConfigurationsParams() *ListLdapConfigurationsParams { - p := &ListLdapConfigurationsParams{} - p.p = make(map[string]interface{}) - return p -} - -// Lists all LDAP configurations -func (s *ConfigurationService) ListLdapConfigurations(p *ListLdapConfigurationsParams) (*ListLdapConfigurationsResponse, error) { - resp, err := s.cs.newRequest("listLdapConfigurations", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListLdapConfigurationsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListLdapConfigurationsResponse struct { - Count int `json:"count"` - LdapConfigurations []*LdapConfiguration `json:"ldapconfiguration"` -} - -type LdapConfiguration struct { - Hostname string `json:"hostname,omitempty"` - Port int `json:"port,omitempty"` -} - -type AddLdapConfigurationParams struct { - p map[string]interface{} -} - -func (p *AddLdapConfigurationParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["hostname"]; found { - u.Set("hostname", v.(string)) - } - if v, found := p.p["port"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("port", vv) - } - return u -} - -func (p *AddLdapConfigurationParams) SetHostname(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hostname"] = v - return -} - -func (p *AddLdapConfigurationParams) SetPort(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["port"] = v - return -} - -// You should always use this function to get a new AddLdapConfigurationParams instance, -// as then you are sure you have configured all required params -func (s *ConfigurationService) NewAddLdapConfigurationParams(hostname string, port int) *AddLdapConfigurationParams { - p := &AddLdapConfigurationParams{} - p.p = make(map[string]interface{}) - p.p["hostname"] = hostname - p.p["port"] = port - return p -} - -// Add a new Ldap Configuration -func (s *ConfigurationService) AddLdapConfiguration(p *AddLdapConfigurationParams) (*AddLdapConfigurationResponse, error) { - resp, err := s.cs.newRequest("addLdapConfiguration", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AddLdapConfigurationResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type AddLdapConfigurationResponse struct { - Hostname string `json:"hostname,omitempty"` - Port int `json:"port,omitempty"` -} - -type DeleteLdapConfigurationParams struct { - p map[string]interface{} -} - -func (p *DeleteLdapConfigurationParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["hostname"]; found { - u.Set("hostname", v.(string)) - } - return u -} - -func (p *DeleteLdapConfigurationParams) SetHostname(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hostname"] = v - return -} - -// You should always use this function to get a new DeleteLdapConfigurationParams instance, -// as then you are sure you have configured all required params -func (s *ConfigurationService) NewDeleteLdapConfigurationParams(hostname string) *DeleteLdapConfigurationParams { - p := &DeleteLdapConfigurationParams{} - p.p = make(map[string]interface{}) - p.p["hostname"] = hostname - return p -} - -// Remove an Ldap Configuration -func (s *ConfigurationService) DeleteLdapConfiguration(p *DeleteLdapConfigurationParams) (*DeleteLdapConfigurationResponse, error) { - resp, err := s.cs.newRequest("deleteLdapConfiguration", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteLdapConfigurationResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type DeleteLdapConfigurationResponse struct { - Hostname string `json:"hostname,omitempty"` - Port int `json:"port,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/DiskOfferingService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/DiskOfferingService.go deleted file mode 100644 index ee85a07e33d..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/DiskOfferingService.go +++ /dev/null @@ -1,688 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type CreateDiskOfferingParams struct { - p map[string]interface{} -} - -func (p *CreateDiskOfferingParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["bytesreadrate"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("bytesreadrate", vv) - } - if v, found := p.p["byteswriterate"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("byteswriterate", vv) - } - if v, found := p.p["customized"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("customized", vv) - } - if v, found := p.p["customizediops"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("customizediops", vv) - } - if v, found := p.p["disksize"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("disksize", vv) - } - if v, found := p.p["displayoffering"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("displayoffering", vv) - } - if v, found := p.p["displaytext"]; found { - u.Set("displaytext", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["hypervisorsnapshotreserve"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("hypervisorsnapshotreserve", vv) - } - if v, found := p.p["iopsreadrate"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("iopsreadrate", vv) - } - if v, found := p.p["iopswriterate"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("iopswriterate", vv) - } - if v, found := p.p["maxiops"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("maxiops", vv) - } - if v, found := p.p["miniops"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("miniops", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["provisioningtype"]; found { - u.Set("provisioningtype", v.(string)) - } - if v, found := p.p["storagetype"]; found { - u.Set("storagetype", v.(string)) - } - if v, found := p.p["tags"]; found { - u.Set("tags", v.(string)) - } - return u -} - -func (p *CreateDiskOfferingParams) SetBytesreadrate(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["bytesreadrate"] = v - return -} - -func (p *CreateDiskOfferingParams) SetByteswriterate(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["byteswriterate"] = v - return -} - -func (p *CreateDiskOfferingParams) SetCustomized(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["customized"] = v - return -} - -func (p *CreateDiskOfferingParams) SetCustomizediops(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["customizediops"] = v - return -} - -func (p *CreateDiskOfferingParams) SetDisksize(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["disksize"] = v - return -} - -func (p *CreateDiskOfferingParams) SetDisplayoffering(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displayoffering"] = v - return -} - -func (p *CreateDiskOfferingParams) SetDisplaytext(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displaytext"] = v - return -} - -func (p *CreateDiskOfferingParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *CreateDiskOfferingParams) SetHypervisorsnapshotreserve(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hypervisorsnapshotreserve"] = v - return -} - -func (p *CreateDiskOfferingParams) SetIopsreadrate(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["iopsreadrate"] = v - return -} - -func (p *CreateDiskOfferingParams) SetIopswriterate(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["iopswriterate"] = v - return -} - -func (p *CreateDiskOfferingParams) SetMaxiops(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["maxiops"] = v - return -} - -func (p *CreateDiskOfferingParams) SetMiniops(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["miniops"] = v - return -} - -func (p *CreateDiskOfferingParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *CreateDiskOfferingParams) SetProvisioningtype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["provisioningtype"] = v - return -} - -func (p *CreateDiskOfferingParams) SetStoragetype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["storagetype"] = v - return -} - -func (p *CreateDiskOfferingParams) SetTags(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tags"] = v - return -} - -// You should always use this function to get a new CreateDiskOfferingParams instance, -// as then you are sure you have configured all required params -func (s *DiskOfferingService) NewCreateDiskOfferingParams(displaytext string, name string) *CreateDiskOfferingParams { - p := &CreateDiskOfferingParams{} - p.p = make(map[string]interface{}) - p.p["displaytext"] = displaytext - p.p["name"] = name - return p -} - -// Creates a disk offering. -func (s *DiskOfferingService) CreateDiskOffering(p *CreateDiskOfferingParams) (*CreateDiskOfferingResponse, error) { - resp, err := s.cs.newRequest("createDiskOffering", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateDiskOfferingResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type CreateDiskOfferingResponse struct { - CacheMode string `json:"cacheMode,omitempty"` - Created string `json:"created,omitempty"` - DiskBytesReadRate int64 `json:"diskBytesReadRate,omitempty"` - DiskBytesWriteRate int64 `json:"diskBytesWriteRate,omitempty"` - DiskIopsReadRate int64 `json:"diskIopsReadRate,omitempty"` - DiskIopsWriteRate int64 `json:"diskIopsWriteRate,omitempty"` - Disksize int64 `json:"disksize,omitempty"` - Displayoffering bool `json:"displayoffering,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Hypervisorsnapshotreserve int `json:"hypervisorsnapshotreserve,omitempty"` - Id string `json:"id,omitempty"` - Iscustomized bool `json:"iscustomized,omitempty"` - Iscustomizediops bool `json:"iscustomizediops,omitempty"` - Maxiops int64 `json:"maxiops,omitempty"` - Miniops int64 `json:"miniops,omitempty"` - Name string `json:"name,omitempty"` - Provisioningtype string `json:"provisioningtype,omitempty"` - Storagetype string `json:"storagetype,omitempty"` - Tags string `json:"tags,omitempty"` -} - -type UpdateDiskOfferingParams struct { - p map[string]interface{} -} - -func (p *UpdateDiskOfferingParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["displayoffering"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("displayoffering", vv) - } - if v, found := p.p["displaytext"]; found { - u.Set("displaytext", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["sortkey"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("sortkey", vv) - } - return u -} - -func (p *UpdateDiskOfferingParams) SetDisplayoffering(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displayoffering"] = v - return -} - -func (p *UpdateDiskOfferingParams) SetDisplaytext(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displaytext"] = v - return -} - -func (p *UpdateDiskOfferingParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateDiskOfferingParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *UpdateDiskOfferingParams) SetSortkey(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["sortkey"] = v - return -} - -// You should always use this function to get a new UpdateDiskOfferingParams instance, -// as then you are sure you have configured all required params -func (s *DiskOfferingService) NewUpdateDiskOfferingParams(id string) *UpdateDiskOfferingParams { - p := &UpdateDiskOfferingParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates a disk offering. -func (s *DiskOfferingService) UpdateDiskOffering(p *UpdateDiskOfferingParams) (*UpdateDiskOfferingResponse, error) { - resp, err := s.cs.newRequest("updateDiskOffering", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateDiskOfferingResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type UpdateDiskOfferingResponse struct { - CacheMode string `json:"cacheMode,omitempty"` - Created string `json:"created,omitempty"` - DiskBytesReadRate int64 `json:"diskBytesReadRate,omitempty"` - DiskBytesWriteRate int64 `json:"diskBytesWriteRate,omitempty"` - DiskIopsReadRate int64 `json:"diskIopsReadRate,omitempty"` - DiskIopsWriteRate int64 `json:"diskIopsWriteRate,omitempty"` - Disksize int64 `json:"disksize,omitempty"` - Displayoffering bool `json:"displayoffering,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Hypervisorsnapshotreserve int `json:"hypervisorsnapshotreserve,omitempty"` - Id string `json:"id,omitempty"` - Iscustomized bool `json:"iscustomized,omitempty"` - Iscustomizediops bool `json:"iscustomizediops,omitempty"` - Maxiops int64 `json:"maxiops,omitempty"` - Miniops int64 `json:"miniops,omitempty"` - Name string `json:"name,omitempty"` - Provisioningtype string `json:"provisioningtype,omitempty"` - Storagetype string `json:"storagetype,omitempty"` - Tags string `json:"tags,omitempty"` -} - -type DeleteDiskOfferingParams struct { - p map[string]interface{} -} - -func (p *DeleteDiskOfferingParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteDiskOfferingParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteDiskOfferingParams instance, -// as then you are sure you have configured all required params -func (s *DiskOfferingService) NewDeleteDiskOfferingParams(id string) *DeleteDiskOfferingParams { - p := &DeleteDiskOfferingParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates a disk offering. -func (s *DiskOfferingService) DeleteDiskOffering(p *DeleteDiskOfferingParams) (*DeleteDiskOfferingResponse, error) { - resp, err := s.cs.newRequest("deleteDiskOffering", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteDiskOfferingResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type DeleteDiskOfferingResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} - -type ListDiskOfferingsParams struct { - p map[string]interface{} -} - -func (p *ListDiskOfferingsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - return u -} - -func (p *ListDiskOfferingsParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListDiskOfferingsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListDiskOfferingsParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListDiskOfferingsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListDiskOfferingsParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListDiskOfferingsParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListDiskOfferingsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListDiskOfferingsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -// You should always use this function to get a new ListDiskOfferingsParams instance, -// as then you are sure you have configured all required params -func (s *DiskOfferingService) NewListDiskOfferingsParams() *ListDiskOfferingsParams { - p := &ListDiskOfferingsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *DiskOfferingService) GetDiskOfferingID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListDiskOfferingsParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListDiskOfferings(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.DiskOfferings[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.DiskOfferings { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *DiskOfferingService) GetDiskOfferingByName(name string, opts ...OptionFunc) (*DiskOffering, int, error) { - id, count, err := s.GetDiskOfferingID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetDiskOfferingByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *DiskOfferingService) GetDiskOfferingByID(id string, opts ...OptionFunc) (*DiskOffering, int, error) { - p := &ListDiskOfferingsParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListDiskOfferings(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.DiskOfferings[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for DiskOffering UUID: %s!", id) -} - -// Lists all available disk offerings. -func (s *DiskOfferingService) ListDiskOfferings(p *ListDiskOfferingsParams) (*ListDiskOfferingsResponse, error) { - resp, err := s.cs.newRequest("listDiskOfferings", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListDiskOfferingsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListDiskOfferingsResponse struct { - Count int `json:"count"` - DiskOfferings []*DiskOffering `json:"diskoffering"` -} - -type DiskOffering struct { - CacheMode string `json:"cacheMode,omitempty"` - Created string `json:"created,omitempty"` - DiskBytesReadRate int64 `json:"diskBytesReadRate,omitempty"` - DiskBytesWriteRate int64 `json:"diskBytesWriteRate,omitempty"` - DiskIopsReadRate int64 `json:"diskIopsReadRate,omitempty"` - DiskIopsWriteRate int64 `json:"diskIopsWriteRate,omitempty"` - Disksize int64 `json:"disksize,omitempty"` - Displayoffering bool `json:"displayoffering,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Hypervisorsnapshotreserve int `json:"hypervisorsnapshotreserve,omitempty"` - Id string `json:"id,omitempty"` - Iscustomized bool `json:"iscustomized,omitempty"` - Iscustomizediops bool `json:"iscustomizediops,omitempty"` - Maxiops int64 `json:"maxiops,omitempty"` - Miniops int64 `json:"miniops,omitempty"` - Name string `json:"name,omitempty"` - Provisioningtype string `json:"provisioningtype,omitempty"` - Storagetype string `json:"storagetype,omitempty"` - Tags string `json:"tags,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/DomainService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/DomainService.go deleted file mode 100644 index 8324e749f8c..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/DomainService.go +++ /dev/null @@ -1,951 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type CreateDomainParams struct { - p map[string]interface{} -} - -func (p *CreateDomainParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["networkdomain"]; found { - u.Set("networkdomain", v.(string)) - } - if v, found := p.p["parentdomainid"]; found { - u.Set("parentdomainid", v.(string)) - } - return u -} - -func (p *CreateDomainParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *CreateDomainParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *CreateDomainParams) SetNetworkdomain(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkdomain"] = v - return -} - -func (p *CreateDomainParams) SetParentdomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["parentdomainid"] = v - return -} - -// You should always use this function to get a new CreateDomainParams instance, -// as then you are sure you have configured all required params -func (s *DomainService) NewCreateDomainParams(name string) *CreateDomainParams { - p := &CreateDomainParams{} - p.p = make(map[string]interface{}) - p.p["name"] = name - return p -} - -// Creates a domain -func (s *DomainService) CreateDomain(p *CreateDomainParams) (*CreateDomainResponse, error) { - resp, err := s.cs.newRequest("createDomain", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateDomainResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type CreateDomainResponse struct { - Cpuavailable string `json:"cpuavailable,omitempty"` - Cpulimit string `json:"cpulimit,omitempty"` - Cputotal int64 `json:"cputotal,omitempty"` - Haschild bool `json:"haschild,omitempty"` - Id string `json:"id,omitempty"` - Ipavailable string `json:"ipavailable,omitempty"` - Iplimit string `json:"iplimit,omitempty"` - Iptotal int64 `json:"iptotal,omitempty"` - Level int `json:"level,omitempty"` - Memoryavailable string `json:"memoryavailable,omitempty"` - Memorylimit string `json:"memorylimit,omitempty"` - Memorytotal int64 `json:"memorytotal,omitempty"` - Name string `json:"name,omitempty"` - Networkavailable string `json:"networkavailable,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Networklimit string `json:"networklimit,omitempty"` - Networktotal int64 `json:"networktotal,omitempty"` - Parentdomainid string `json:"parentdomainid,omitempty"` - Parentdomainname string `json:"parentdomainname,omitempty"` - Path string `json:"path,omitempty"` - Primarystorageavailable string `json:"primarystorageavailable,omitempty"` - Primarystoragelimit string `json:"primarystoragelimit,omitempty"` - Primarystoragetotal int64 `json:"primarystoragetotal,omitempty"` - Projectavailable string `json:"projectavailable,omitempty"` - Projectlimit string `json:"projectlimit,omitempty"` - Projecttotal int64 `json:"projecttotal,omitempty"` - Secondarystorageavailable string `json:"secondarystorageavailable,omitempty"` - Secondarystoragelimit string `json:"secondarystoragelimit,omitempty"` - Secondarystoragetotal int64 `json:"secondarystoragetotal,omitempty"` - Snapshotavailable string `json:"snapshotavailable,omitempty"` - Snapshotlimit string `json:"snapshotlimit,omitempty"` - Snapshottotal int64 `json:"snapshottotal,omitempty"` - State string `json:"state,omitempty"` - Templateavailable string `json:"templateavailable,omitempty"` - Templatelimit string `json:"templatelimit,omitempty"` - Templatetotal int64 `json:"templatetotal,omitempty"` - Vmavailable string `json:"vmavailable,omitempty"` - Vmlimit string `json:"vmlimit,omitempty"` - Vmtotal int64 `json:"vmtotal,omitempty"` - Volumeavailable string `json:"volumeavailable,omitempty"` - Volumelimit string `json:"volumelimit,omitempty"` - Volumetotal int64 `json:"volumetotal,omitempty"` - Vpcavailable string `json:"vpcavailable,omitempty"` - Vpclimit string `json:"vpclimit,omitempty"` - Vpctotal int64 `json:"vpctotal,omitempty"` -} - -type UpdateDomainParams struct { - p map[string]interface{} -} - -func (p *UpdateDomainParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["networkdomain"]; found { - u.Set("networkdomain", v.(string)) - } - return u -} - -func (p *UpdateDomainParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateDomainParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *UpdateDomainParams) SetNetworkdomain(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkdomain"] = v - return -} - -// You should always use this function to get a new UpdateDomainParams instance, -// as then you are sure you have configured all required params -func (s *DomainService) NewUpdateDomainParams(id string) *UpdateDomainParams { - p := &UpdateDomainParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates a domain with a new name -func (s *DomainService) UpdateDomain(p *UpdateDomainParams) (*UpdateDomainResponse, error) { - resp, err := s.cs.newRequest("updateDomain", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateDomainResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type UpdateDomainResponse struct { - Cpuavailable string `json:"cpuavailable,omitempty"` - Cpulimit string `json:"cpulimit,omitempty"` - Cputotal int64 `json:"cputotal,omitempty"` - Haschild bool `json:"haschild,omitempty"` - Id string `json:"id,omitempty"` - Ipavailable string `json:"ipavailable,omitempty"` - Iplimit string `json:"iplimit,omitempty"` - Iptotal int64 `json:"iptotal,omitempty"` - Level int `json:"level,omitempty"` - Memoryavailable string `json:"memoryavailable,omitempty"` - Memorylimit string `json:"memorylimit,omitempty"` - Memorytotal int64 `json:"memorytotal,omitempty"` - Name string `json:"name,omitempty"` - Networkavailable string `json:"networkavailable,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Networklimit string `json:"networklimit,omitempty"` - Networktotal int64 `json:"networktotal,omitempty"` - Parentdomainid string `json:"parentdomainid,omitempty"` - Parentdomainname string `json:"parentdomainname,omitempty"` - Path string `json:"path,omitempty"` - Primarystorageavailable string `json:"primarystorageavailable,omitempty"` - Primarystoragelimit string `json:"primarystoragelimit,omitempty"` - Primarystoragetotal int64 `json:"primarystoragetotal,omitempty"` - Projectavailable string `json:"projectavailable,omitempty"` - Projectlimit string `json:"projectlimit,omitempty"` - Projecttotal int64 `json:"projecttotal,omitempty"` - Secondarystorageavailable string `json:"secondarystorageavailable,omitempty"` - Secondarystoragelimit string `json:"secondarystoragelimit,omitempty"` - Secondarystoragetotal int64 `json:"secondarystoragetotal,omitempty"` - Snapshotavailable string `json:"snapshotavailable,omitempty"` - Snapshotlimit string `json:"snapshotlimit,omitempty"` - Snapshottotal int64 `json:"snapshottotal,omitempty"` - State string `json:"state,omitempty"` - Templateavailable string `json:"templateavailable,omitempty"` - Templatelimit string `json:"templatelimit,omitempty"` - Templatetotal int64 `json:"templatetotal,omitempty"` - Vmavailable string `json:"vmavailable,omitempty"` - Vmlimit string `json:"vmlimit,omitempty"` - Vmtotal int64 `json:"vmtotal,omitempty"` - Volumeavailable string `json:"volumeavailable,omitempty"` - Volumelimit string `json:"volumelimit,omitempty"` - Volumetotal int64 `json:"volumetotal,omitempty"` - Vpcavailable string `json:"vpcavailable,omitempty"` - Vpclimit string `json:"vpclimit,omitempty"` - Vpctotal int64 `json:"vpctotal,omitempty"` -} - -type DeleteDomainParams struct { - p map[string]interface{} -} - -func (p *DeleteDomainParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["cleanup"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("cleanup", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteDomainParams) SetCleanup(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["cleanup"] = v - return -} - -func (p *DeleteDomainParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteDomainParams instance, -// as then you are sure you have configured all required params -func (s *DomainService) NewDeleteDomainParams(id string) *DeleteDomainParams { - p := &DeleteDomainParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a specified domain -func (s *DomainService) DeleteDomain(p *DeleteDomainParams) (*DeleteDomainResponse, error) { - resp, err := s.cs.newRequest("deleteDomain", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteDomainResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteDomainResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListDomainsParams struct { - p map[string]interface{} -} - -func (p *ListDomainsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["level"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("level", vv) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - return u -} - -func (p *ListDomainsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListDomainsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListDomainsParams) SetLevel(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["level"] = v - return -} - -func (p *ListDomainsParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListDomainsParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListDomainsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListDomainsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -// You should always use this function to get a new ListDomainsParams instance, -// as then you are sure you have configured all required params -func (s *DomainService) NewListDomainsParams() *ListDomainsParams { - p := &ListDomainsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *DomainService) GetDomainID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListDomainsParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListDomains(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.Domains[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.Domains { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *DomainService) GetDomainByName(name string, opts ...OptionFunc) (*Domain, int, error) { - id, count, err := s.GetDomainID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetDomainByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *DomainService) GetDomainByID(id string, opts ...OptionFunc) (*Domain, int, error) { - p := &ListDomainsParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListDomains(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.Domains[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for Domain UUID: %s!", id) -} - -// Lists domains and provides detailed information for listed domains -func (s *DomainService) ListDomains(p *ListDomainsParams) (*ListDomainsResponse, error) { - resp, err := s.cs.newRequest("listDomains", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListDomainsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListDomainsResponse struct { - Count int `json:"count"` - Domains []*Domain `json:"domain"` -} - -type Domain struct { - Cpuavailable string `json:"cpuavailable,omitempty"` - Cpulimit string `json:"cpulimit,omitempty"` - Cputotal int64 `json:"cputotal,omitempty"` - Haschild bool `json:"haschild,omitempty"` - Id string `json:"id,omitempty"` - Ipavailable string `json:"ipavailable,omitempty"` - Iplimit string `json:"iplimit,omitempty"` - Iptotal int64 `json:"iptotal,omitempty"` - Level int `json:"level,omitempty"` - Memoryavailable string `json:"memoryavailable,omitempty"` - Memorylimit string `json:"memorylimit,omitempty"` - Memorytotal int64 `json:"memorytotal,omitempty"` - Name string `json:"name,omitempty"` - Networkavailable string `json:"networkavailable,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Networklimit string `json:"networklimit,omitempty"` - Networktotal int64 `json:"networktotal,omitempty"` - Parentdomainid string `json:"parentdomainid,omitempty"` - Parentdomainname string `json:"parentdomainname,omitempty"` - Path string `json:"path,omitempty"` - Primarystorageavailable string `json:"primarystorageavailable,omitempty"` - Primarystoragelimit string `json:"primarystoragelimit,omitempty"` - Primarystoragetotal int64 `json:"primarystoragetotal,omitempty"` - Projectavailable string `json:"projectavailable,omitempty"` - Projectlimit string `json:"projectlimit,omitempty"` - Projecttotal int64 `json:"projecttotal,omitempty"` - Secondarystorageavailable string `json:"secondarystorageavailable,omitempty"` - Secondarystoragelimit string `json:"secondarystoragelimit,omitempty"` - Secondarystoragetotal int64 `json:"secondarystoragetotal,omitempty"` - Snapshotavailable string `json:"snapshotavailable,omitempty"` - Snapshotlimit string `json:"snapshotlimit,omitempty"` - Snapshottotal int64 `json:"snapshottotal,omitempty"` - State string `json:"state,omitempty"` - Templateavailable string `json:"templateavailable,omitempty"` - Templatelimit string `json:"templatelimit,omitempty"` - Templatetotal int64 `json:"templatetotal,omitempty"` - Vmavailable string `json:"vmavailable,omitempty"` - Vmlimit string `json:"vmlimit,omitempty"` - Vmtotal int64 `json:"vmtotal,omitempty"` - Volumeavailable string `json:"volumeavailable,omitempty"` - Volumelimit string `json:"volumelimit,omitempty"` - Volumetotal int64 `json:"volumetotal,omitempty"` - Vpcavailable string `json:"vpcavailable,omitempty"` - Vpclimit string `json:"vpclimit,omitempty"` - Vpctotal int64 `json:"vpctotal,omitempty"` -} - -type ListDomainChildrenParams struct { - p map[string]interface{} -} - -func (p *ListDomainChildrenParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - return u -} - -func (p *ListDomainChildrenParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListDomainChildrenParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListDomainChildrenParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListDomainChildrenParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListDomainChildrenParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListDomainChildrenParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListDomainChildrenParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -// You should always use this function to get a new ListDomainChildrenParams instance, -// as then you are sure you have configured all required params -func (s *DomainService) NewListDomainChildrenParams() *ListDomainChildrenParams { - p := &ListDomainChildrenParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *DomainService) GetDomainChildrenID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListDomainChildrenParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListDomainChildren(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.DomainChildren[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.DomainChildren { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *DomainService) GetDomainChildrenByName(name string, opts ...OptionFunc) (*DomainChildren, int, error) { - id, count, err := s.GetDomainChildrenID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetDomainChildrenByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *DomainService) GetDomainChildrenByID(id string, opts ...OptionFunc) (*DomainChildren, int, error) { - p := &ListDomainChildrenParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListDomainChildren(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.DomainChildren[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for DomainChildren UUID: %s!", id) -} - -// Lists all children domains belonging to a specified domain -func (s *DomainService) ListDomainChildren(p *ListDomainChildrenParams) (*ListDomainChildrenResponse, error) { - resp, err := s.cs.newRequest("listDomainChildren", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListDomainChildrenResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListDomainChildrenResponse struct { - Count int `json:"count"` - DomainChildren []*DomainChildren `json:"domainchildren"` -} - -type DomainChildren struct { - Cpuavailable string `json:"cpuavailable,omitempty"` - Cpulimit string `json:"cpulimit,omitempty"` - Cputotal int64 `json:"cputotal,omitempty"` - Haschild bool `json:"haschild,omitempty"` - Id string `json:"id,omitempty"` - Ipavailable string `json:"ipavailable,omitempty"` - Iplimit string `json:"iplimit,omitempty"` - Iptotal int64 `json:"iptotal,omitempty"` - Level int `json:"level,omitempty"` - Memoryavailable string `json:"memoryavailable,omitempty"` - Memorylimit string `json:"memorylimit,omitempty"` - Memorytotal int64 `json:"memorytotal,omitempty"` - Name string `json:"name,omitempty"` - Networkavailable string `json:"networkavailable,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Networklimit string `json:"networklimit,omitempty"` - Networktotal int64 `json:"networktotal,omitempty"` - Parentdomainid string `json:"parentdomainid,omitempty"` - Parentdomainname string `json:"parentdomainname,omitempty"` - Path string `json:"path,omitempty"` - Primarystorageavailable string `json:"primarystorageavailable,omitempty"` - Primarystoragelimit string `json:"primarystoragelimit,omitempty"` - Primarystoragetotal int64 `json:"primarystoragetotal,omitempty"` - Projectavailable string `json:"projectavailable,omitempty"` - Projectlimit string `json:"projectlimit,omitempty"` - Projecttotal int64 `json:"projecttotal,omitempty"` - Secondarystorageavailable string `json:"secondarystorageavailable,omitempty"` - Secondarystoragelimit string `json:"secondarystoragelimit,omitempty"` - Secondarystoragetotal int64 `json:"secondarystoragetotal,omitempty"` - Snapshotavailable string `json:"snapshotavailable,omitempty"` - Snapshotlimit string `json:"snapshotlimit,omitempty"` - Snapshottotal int64 `json:"snapshottotal,omitempty"` - State string `json:"state,omitempty"` - Templateavailable string `json:"templateavailable,omitempty"` - Templatelimit string `json:"templatelimit,omitempty"` - Templatetotal int64 `json:"templatetotal,omitempty"` - Vmavailable string `json:"vmavailable,omitempty"` - Vmlimit string `json:"vmlimit,omitempty"` - Vmtotal int64 `json:"vmtotal,omitempty"` - Volumeavailable string `json:"volumeavailable,omitempty"` - Volumelimit string `json:"volumelimit,omitempty"` - Volumetotal int64 `json:"volumetotal,omitempty"` - Vpcavailable string `json:"vpcavailable,omitempty"` - Vpclimit string `json:"vpclimit,omitempty"` - Vpctotal int64 `json:"vpctotal,omitempty"` -} - -type LinkDomainToLdapParams struct { - p map[string]interface{} -} - -func (p *LinkDomainToLdapParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["accounttype"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("accounttype", vv) - } - if v, found := p.p["admin"]; found { - u.Set("admin", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["type"]; found { - u.Set("type", v.(string)) - } - return u -} - -func (p *LinkDomainToLdapParams) SetAccounttype(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["accounttype"] = v - return -} - -func (p *LinkDomainToLdapParams) SetAdmin(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["admin"] = v - return -} - -func (p *LinkDomainToLdapParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *LinkDomainToLdapParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *LinkDomainToLdapParams) SetType(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainType"] = v - return -} - -// You should always use this function to get a new LinkDomainToLdapParams instance, -// as then you are sure you have configured all required params -func (s *DomainService) NewLinkDomainToLdapParams(accounttype int, domainid string, name string, domainType string) *LinkDomainToLdapParams { - p := &LinkDomainToLdapParams{} - p.p = make(map[string]interface{}) - p.p["accounttype"] = accounttype - p.p["domainid"] = domainid - p.p["name"] = name - p.p["domainType"] = domainType - return p -} - -// link an existing cloudstack domain to group or OU in ldap -func (s *DomainService) LinkDomainToLdap(p *LinkDomainToLdapParams) (*LinkDomainToLdapResponse, error) { - resp, err := s.cs.newRequest("linkDomainToLdap", p.toURLValues()) - if err != nil { - return nil, err - } - - var r LinkDomainToLdapResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type LinkDomainToLdapResponse struct { - Accountid string `json:"accountid,omitempty"` - Accounttype int `json:"accounttype,omitempty"` - Domainid int64 `json:"domainid,omitempty"` - Name string `json:"name,omitempty"` - Type string `json:"type,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/EventService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/EventService.go deleted file mode 100644 index dee82971338..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/EventService.go +++ /dev/null @@ -1,495 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type ListEventsParams struct { - p map[string]interface{} -} - -func (p *ListEventsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["duration"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("duration", vv) - } - if v, found := p.p["enddate"]; found { - u.Set("enddate", v.(string)) - } - if v, found := p.p["entrytime"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("entrytime", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["level"]; found { - u.Set("level", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["startdate"]; found { - u.Set("startdate", v.(string)) - } - if v, found := p.p["type"]; found { - u.Set("type", v.(string)) - } - return u -} - -func (p *ListEventsParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListEventsParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListEventsParams) SetDuration(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["duration"] = v - return -} - -func (p *ListEventsParams) SetEnddate(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["enddate"] = v - return -} - -func (p *ListEventsParams) SetEntrytime(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["entrytime"] = v - return -} - -func (p *ListEventsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListEventsParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListEventsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListEventsParams) SetLevel(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["level"] = v - return -} - -func (p *ListEventsParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListEventsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListEventsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListEventsParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListEventsParams) SetStartdate(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["startdate"] = v - return -} - -func (p *ListEventsParams) SetType(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["eventType"] = v - return -} - -// You should always use this function to get a new ListEventsParams instance, -// as then you are sure you have configured all required params -func (s *EventService) NewListEventsParams() *ListEventsParams { - p := &ListEventsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *EventService) GetEventByID(id string, opts ...OptionFunc) (*Event, int, error) { - p := &ListEventsParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListEvents(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.Events[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for Event UUID: %s!", id) -} - -// A command to list events. -func (s *EventService) ListEvents(p *ListEventsParams) (*ListEventsResponse, error) { - resp, err := s.cs.newRequest("listEvents", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListEventsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListEventsResponse struct { - Count int `json:"count"` - Events []*Event `json:"event"` -} - -type Event struct { - Account string `json:"account,omitempty"` - Created string `json:"created,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Level string `json:"level,omitempty"` - Parentid string `json:"parentid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - State string `json:"state,omitempty"` - Type string `json:"type,omitempty"` - Username string `json:"username,omitempty"` -} - -type ListEventTypesParams struct { - p map[string]interface{} -} - -func (p *ListEventTypesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - return u -} - -// You should always use this function to get a new ListEventTypesParams instance, -// as then you are sure you have configured all required params -func (s *EventService) NewListEventTypesParams() *ListEventTypesParams { - p := &ListEventTypesParams{} - p.p = make(map[string]interface{}) - return p -} - -// List Event Types -func (s *EventService) ListEventTypes(p *ListEventTypesParams) (*ListEventTypesResponse, error) { - resp, err := s.cs.newRequest("listEventTypes", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListEventTypesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListEventTypesResponse struct { - Count int `json:"count"` - EventTypes []*EventType `json:"eventtype"` -} - -type EventType struct { - Name string `json:"name,omitempty"` -} - -type ArchiveEventsParams struct { - p map[string]interface{} -} - -func (p *ArchiveEventsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["enddate"]; found { - u.Set("enddate", v.(string)) - } - if v, found := p.p["ids"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("ids", vv) - } - if v, found := p.p["startdate"]; found { - u.Set("startdate", v.(string)) - } - if v, found := p.p["type"]; found { - u.Set("type", v.(string)) - } - return u -} - -func (p *ArchiveEventsParams) SetEnddate(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["enddate"] = v - return -} - -func (p *ArchiveEventsParams) SetIds(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ids"] = v - return -} - -func (p *ArchiveEventsParams) SetStartdate(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["startdate"] = v - return -} - -func (p *ArchiveEventsParams) SetType(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["eventType"] = v - return -} - -// You should always use this function to get a new ArchiveEventsParams instance, -// as then you are sure you have configured all required params -func (s *EventService) NewArchiveEventsParams() *ArchiveEventsParams { - p := &ArchiveEventsParams{} - p.p = make(map[string]interface{}) - return p -} - -// Archive one or more events. -func (s *EventService) ArchiveEvents(p *ArchiveEventsParams) (*ArchiveEventsResponse, error) { - resp, err := s.cs.newRequest("archiveEvents", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ArchiveEventsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ArchiveEventsResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} - -type DeleteEventsParams struct { - p map[string]interface{} -} - -func (p *DeleteEventsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["enddate"]; found { - u.Set("enddate", v.(string)) - } - if v, found := p.p["ids"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("ids", vv) - } - if v, found := p.p["startdate"]; found { - u.Set("startdate", v.(string)) - } - if v, found := p.p["type"]; found { - u.Set("type", v.(string)) - } - return u -} - -func (p *DeleteEventsParams) SetEnddate(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["enddate"] = v - return -} - -func (p *DeleteEventsParams) SetIds(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ids"] = v - return -} - -func (p *DeleteEventsParams) SetStartdate(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["startdate"] = v - return -} - -func (p *DeleteEventsParams) SetType(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["eventType"] = v - return -} - -// You should always use this function to get a new DeleteEventsParams instance, -// as then you are sure you have configured all required params -func (s *EventService) NewDeleteEventsParams() *DeleteEventsParams { - p := &DeleteEventsParams{} - p.p = make(map[string]interface{}) - return p -} - -// Delete one or more events. -func (s *EventService) DeleteEvents(p *DeleteEventsParams) (*DeleteEventsResponse, error) { - resp, err := s.cs.newRequest("deleteEvents", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteEventsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type DeleteEventsResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/FirewallService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/FirewallService.go deleted file mode 100644 index 3c7c17ddb2a..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/FirewallService.go +++ /dev/null @@ -1,2587 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -// Helper function for maintaining backwards compatibility -func convertFirewallServiceResponse(b []byte) ([]byte, error) { - var raw map[string]interface{} - if err := json.Unmarshal(b, &raw); err != nil { - return nil, err - } - - if _, ok := raw["firewallrule"]; ok { - return convertFirewallServiceListResponse(b) - } - - for _, k := range []string{"endport", "startport"} { - if sVal, ok := raw[k].(string); ok { - iVal, err := strconv.Atoi(sVal) - if err != nil { - return nil, err - } - raw[k] = iVal - } - } - - return json.Marshal(raw) -} - -// Helper function for maintaining backwards compatibility -func convertFirewallServiceListResponse(b []byte) ([]byte, error) { - var rawList struct { - Count int `json:"count"` - FirewallRules []map[string]interface{} `json:"firewallrule"` - } - - if err := json.Unmarshal(b, &rawList); err != nil { - return nil, err - } - - for _, r := range rawList.FirewallRules { - for _, k := range []string{"endport", "startport"} { - if sVal, ok := r[k].(string); ok { - iVal, err := strconv.Atoi(sVal) - if err != nil { - return nil, err - } - r[k] = iVal - } - } - } - - return json.Marshal(rawList) -} - -type ListPortForwardingRulesParams struct { - p map[string]interface{} -} - -func (p *ListPortForwardingRulesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["ipaddressid"]; found { - u.Set("ipaddressid", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["networkid"]; found { - u.Set("networkid", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["tags"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("tags[%d].key", i), k) - u.Set(fmt.Sprintf("tags[%d].value", i), vv) - i++ - } - } - return u -} - -func (p *ListPortForwardingRulesParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListPortForwardingRulesParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListPortForwardingRulesParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *ListPortForwardingRulesParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListPortForwardingRulesParams) SetIpaddressid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ipaddressid"] = v - return -} - -func (p *ListPortForwardingRulesParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListPortForwardingRulesParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListPortForwardingRulesParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListPortForwardingRulesParams) SetNetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkid"] = v - return -} - -func (p *ListPortForwardingRulesParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListPortForwardingRulesParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListPortForwardingRulesParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListPortForwardingRulesParams) SetTags(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tags"] = v - return -} - -// You should always use this function to get a new ListPortForwardingRulesParams instance, -// as then you are sure you have configured all required params -func (s *FirewallService) NewListPortForwardingRulesParams() *ListPortForwardingRulesParams { - p := &ListPortForwardingRulesParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *FirewallService) GetPortForwardingRuleByID(id string, opts ...OptionFunc) (*PortForwardingRule, int, error) { - p := &ListPortForwardingRulesParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListPortForwardingRules(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.PortForwardingRules[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for PortForwardingRule UUID: %s!", id) -} - -// Lists all port forwarding rules for an IP address. -func (s *FirewallService) ListPortForwardingRules(p *ListPortForwardingRulesParams) (*ListPortForwardingRulesResponse, error) { - resp, err := s.cs.newRequest("listPortForwardingRules", p.toURLValues()) - if err != nil { - return nil, err - } - - resp, err = convertFirewallServiceResponse(resp) - if err != nil { - return nil, err - } - - var r ListPortForwardingRulesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListPortForwardingRulesResponse struct { - Count int `json:"count"` - PortForwardingRules []*PortForwardingRule `json:"portforwardingrule"` -} - -type PortForwardingRule struct { - Cidrlist string `json:"cidrlist,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Ipaddressid string `json:"ipaddressid,omitempty"` - Networkid string `json:"networkid,omitempty"` - Privateendport string `json:"privateendport,omitempty"` - Privateport string `json:"privateport,omitempty"` - Protocol string `json:"protocol,omitempty"` - Publicendport string `json:"publicendport,omitempty"` - Publicport string `json:"publicport,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinedisplayname string `json:"virtualmachinedisplayname,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - Virtualmachinename string `json:"virtualmachinename,omitempty"` - Vmguestip string `json:"vmguestip,omitempty"` -} - -type CreatePortForwardingRuleParams struct { - p map[string]interface{} -} - -func (p *CreatePortForwardingRuleParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["cidrlist"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("cidrlist", vv) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["ipaddressid"]; found { - u.Set("ipaddressid", v.(string)) - } - if v, found := p.p["networkid"]; found { - u.Set("networkid", v.(string)) - } - if v, found := p.p["openfirewall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("openfirewall", vv) - } - if v, found := p.p["privateendport"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("privateendport", vv) - } - if v, found := p.p["privateport"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("privateport", vv) - } - if v, found := p.p["protocol"]; found { - u.Set("protocol", v.(string)) - } - if v, found := p.p["publicendport"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("publicendport", vv) - } - if v, found := p.p["publicport"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("publicport", vv) - } - if v, found := p.p["virtualmachineid"]; found { - u.Set("virtualmachineid", v.(string)) - } - if v, found := p.p["vmguestip"]; found { - u.Set("vmguestip", v.(string)) - } - return u -} - -func (p *CreatePortForwardingRuleParams) SetCidrlist(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["cidrlist"] = v - return -} - -func (p *CreatePortForwardingRuleParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *CreatePortForwardingRuleParams) SetIpaddressid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ipaddressid"] = v - return -} - -func (p *CreatePortForwardingRuleParams) SetNetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkid"] = v - return -} - -func (p *CreatePortForwardingRuleParams) SetOpenfirewall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["openfirewall"] = v - return -} - -func (p *CreatePortForwardingRuleParams) SetPrivateendport(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["privateendport"] = v - return -} - -func (p *CreatePortForwardingRuleParams) SetPrivateport(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["privateport"] = v - return -} - -func (p *CreatePortForwardingRuleParams) SetProtocol(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["protocol"] = v - return -} - -func (p *CreatePortForwardingRuleParams) SetPublicendport(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["publicendport"] = v - return -} - -func (p *CreatePortForwardingRuleParams) SetPublicport(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["publicport"] = v - return -} - -func (p *CreatePortForwardingRuleParams) SetVirtualmachineid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["virtualmachineid"] = v - return -} - -func (p *CreatePortForwardingRuleParams) SetVmguestip(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vmguestip"] = v - return -} - -// You should always use this function to get a new CreatePortForwardingRuleParams instance, -// as then you are sure you have configured all required params -func (s *FirewallService) NewCreatePortForwardingRuleParams(ipaddressid string, privateport int, protocol string, publicport int, virtualmachineid string) *CreatePortForwardingRuleParams { - p := &CreatePortForwardingRuleParams{} - p.p = make(map[string]interface{}) - p.p["ipaddressid"] = ipaddressid - p.p["privateport"] = privateport - p.p["protocol"] = protocol - p.p["publicport"] = publicport - p.p["virtualmachineid"] = virtualmachineid - return p -} - -// Creates a port forwarding rule -func (s *FirewallService) CreatePortForwardingRule(p *CreatePortForwardingRuleParams) (*CreatePortForwardingRuleResponse, error) { - resp, err := s.cs.newRequest("createPortForwardingRule", p.toURLValues()) - if err != nil { - return nil, err - } - - resp, err = convertFirewallServiceResponse(resp) - if err != nil { - return nil, err - } - - var r CreatePortForwardingRuleResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - b, err = convertFirewallServiceResponse(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreatePortForwardingRuleResponse struct { - JobID string `json:"jobid,omitempty"` - Cidrlist string `json:"cidrlist,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Ipaddressid string `json:"ipaddressid,omitempty"` - Networkid string `json:"networkid,omitempty"` - Privateendport string `json:"privateendport,omitempty"` - Privateport string `json:"privateport,omitempty"` - Protocol string `json:"protocol,omitempty"` - Publicendport string `json:"publicendport,omitempty"` - Publicport string `json:"publicport,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinedisplayname string `json:"virtualmachinedisplayname,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - Virtualmachinename string `json:"virtualmachinename,omitempty"` - Vmguestip string `json:"vmguestip,omitempty"` -} - -type DeletePortForwardingRuleParams struct { - p map[string]interface{} -} - -func (p *DeletePortForwardingRuleParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeletePortForwardingRuleParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeletePortForwardingRuleParams instance, -// as then you are sure you have configured all required params -func (s *FirewallService) NewDeletePortForwardingRuleParams(id string) *DeletePortForwardingRuleParams { - p := &DeletePortForwardingRuleParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a port forwarding rule -func (s *FirewallService) DeletePortForwardingRule(p *DeletePortForwardingRuleParams) (*DeletePortForwardingRuleResponse, error) { - resp, err := s.cs.newRequest("deletePortForwardingRule", p.toURLValues()) - if err != nil { - return nil, err - } - - resp, err = convertFirewallServiceResponse(resp) - if err != nil { - return nil, err - } - - var r DeletePortForwardingRuleResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = convertFirewallServiceResponse(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeletePortForwardingRuleResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type UpdatePortForwardingRuleParams struct { - p map[string]interface{} -} - -func (p *UpdatePortForwardingRuleParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["customid"]; found { - u.Set("customid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["privateport"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("privateport", vv) - } - if v, found := p.p["virtualmachineid"]; found { - u.Set("virtualmachineid", v.(string)) - } - if v, found := p.p["vmguestip"]; found { - u.Set("vmguestip", v.(string)) - } - return u -} - -func (p *UpdatePortForwardingRuleParams) SetCustomid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["customid"] = v - return -} - -func (p *UpdatePortForwardingRuleParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *UpdatePortForwardingRuleParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdatePortForwardingRuleParams) SetPrivateport(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["privateport"] = v - return -} - -func (p *UpdatePortForwardingRuleParams) SetVirtualmachineid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["virtualmachineid"] = v - return -} - -func (p *UpdatePortForwardingRuleParams) SetVmguestip(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vmguestip"] = v - return -} - -// You should always use this function to get a new UpdatePortForwardingRuleParams instance, -// as then you are sure you have configured all required params -func (s *FirewallService) NewUpdatePortForwardingRuleParams(id string) *UpdatePortForwardingRuleParams { - p := &UpdatePortForwardingRuleParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates a port forwarding rule. Only the private port and the virtual machine can be updated. -func (s *FirewallService) UpdatePortForwardingRule(p *UpdatePortForwardingRuleParams) (*UpdatePortForwardingRuleResponse, error) { - resp, err := s.cs.newRequest("updatePortForwardingRule", p.toURLValues()) - if err != nil { - return nil, err - } - - resp, err = convertFirewallServiceResponse(resp) - if err != nil { - return nil, err - } - - var r UpdatePortForwardingRuleResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - b, err = convertFirewallServiceResponse(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdatePortForwardingRuleResponse struct { - JobID string `json:"jobid,omitempty"` - Cidrlist string `json:"cidrlist,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Ipaddressid string `json:"ipaddressid,omitempty"` - Networkid string `json:"networkid,omitempty"` - Privateendport string `json:"privateendport,omitempty"` - Privateport string `json:"privateport,omitempty"` - Protocol string `json:"protocol,omitempty"` - Publicendport string `json:"publicendport,omitempty"` - Publicport string `json:"publicport,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinedisplayname string `json:"virtualmachinedisplayname,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - Virtualmachinename string `json:"virtualmachinename,omitempty"` - Vmguestip string `json:"vmguestip,omitempty"` -} - -type CreateFirewallRuleParams struct { - p map[string]interface{} -} - -func (p *CreateFirewallRuleParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["cidrlist"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("cidrlist", vv) - } - if v, found := p.p["endport"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("endport", vv) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["icmpcode"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("icmpcode", vv) - } - if v, found := p.p["icmptype"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("icmptype", vv) - } - if v, found := p.p["ipaddressid"]; found { - u.Set("ipaddressid", v.(string)) - } - if v, found := p.p["protocol"]; found { - u.Set("protocol", v.(string)) - } - if v, found := p.p["startport"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("startport", vv) - } - if v, found := p.p["type"]; found { - u.Set("type", v.(string)) - } - return u -} - -func (p *CreateFirewallRuleParams) SetCidrlist(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["cidrlist"] = v - return -} - -func (p *CreateFirewallRuleParams) SetEndport(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["endport"] = v - return -} - -func (p *CreateFirewallRuleParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *CreateFirewallRuleParams) SetIcmpcode(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["icmpcode"] = v - return -} - -func (p *CreateFirewallRuleParams) SetIcmptype(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["icmptype"] = v - return -} - -func (p *CreateFirewallRuleParams) SetIpaddressid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ipaddressid"] = v - return -} - -func (p *CreateFirewallRuleParams) SetProtocol(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["protocol"] = v - return -} - -func (p *CreateFirewallRuleParams) SetStartport(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["startport"] = v - return -} - -func (p *CreateFirewallRuleParams) SetType(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["firewallType"] = v - return -} - -// You should always use this function to get a new CreateFirewallRuleParams instance, -// as then you are sure you have configured all required params -func (s *FirewallService) NewCreateFirewallRuleParams(ipaddressid string, protocol string) *CreateFirewallRuleParams { - p := &CreateFirewallRuleParams{} - p.p = make(map[string]interface{}) - p.p["ipaddressid"] = ipaddressid - p.p["protocol"] = protocol - return p -} - -// Creates a firewall rule for a given IP address -func (s *FirewallService) CreateFirewallRule(p *CreateFirewallRuleParams) (*CreateFirewallRuleResponse, error) { - resp, err := s.cs.newRequest("createFirewallRule", p.toURLValues()) - if err != nil { - return nil, err - } - - resp, err = convertFirewallServiceResponse(resp) - if err != nil { - return nil, err - } - - var r CreateFirewallRuleResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - b, err = convertFirewallServiceResponse(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateFirewallRuleResponse struct { - JobID string `json:"jobid,omitempty"` - Cidrlist string `json:"cidrlist,omitempty"` - Endport int `json:"endport,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Ipaddressid string `json:"ipaddressid,omitempty"` - Networkid string `json:"networkid,omitempty"` - Protocol string `json:"protocol,omitempty"` - Startport int `json:"startport,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` -} - -type DeleteFirewallRuleParams struct { - p map[string]interface{} -} - -func (p *DeleteFirewallRuleParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteFirewallRuleParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteFirewallRuleParams instance, -// as then you are sure you have configured all required params -func (s *FirewallService) NewDeleteFirewallRuleParams(id string) *DeleteFirewallRuleParams { - p := &DeleteFirewallRuleParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a firewall rule -func (s *FirewallService) DeleteFirewallRule(p *DeleteFirewallRuleParams) (*DeleteFirewallRuleResponse, error) { - resp, err := s.cs.newRequest("deleteFirewallRule", p.toURLValues()) - if err != nil { - return nil, err - } - - resp, err = convertFirewallServiceResponse(resp) - if err != nil { - return nil, err - } - - var r DeleteFirewallRuleResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = convertFirewallServiceResponse(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteFirewallRuleResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListFirewallRulesParams struct { - p map[string]interface{} -} - -func (p *ListFirewallRulesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["ipaddressid"]; found { - u.Set("ipaddressid", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["networkid"]; found { - u.Set("networkid", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["tags"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("tags[%d].key", i), k) - u.Set(fmt.Sprintf("tags[%d].value", i), vv) - i++ - } - } - return u -} - -func (p *ListFirewallRulesParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListFirewallRulesParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListFirewallRulesParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *ListFirewallRulesParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListFirewallRulesParams) SetIpaddressid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ipaddressid"] = v - return -} - -func (p *ListFirewallRulesParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListFirewallRulesParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListFirewallRulesParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListFirewallRulesParams) SetNetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkid"] = v - return -} - -func (p *ListFirewallRulesParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListFirewallRulesParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListFirewallRulesParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListFirewallRulesParams) SetTags(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tags"] = v - return -} - -// You should always use this function to get a new ListFirewallRulesParams instance, -// as then you are sure you have configured all required params -func (s *FirewallService) NewListFirewallRulesParams() *ListFirewallRulesParams { - p := &ListFirewallRulesParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *FirewallService) GetFirewallRuleByID(id string, opts ...OptionFunc) (*FirewallRule, int, error) { - p := &ListFirewallRulesParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListFirewallRules(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.FirewallRules[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for FirewallRule UUID: %s!", id) -} - -// Lists all firewall rules for an IP address. -func (s *FirewallService) ListFirewallRules(p *ListFirewallRulesParams) (*ListFirewallRulesResponse, error) { - resp, err := s.cs.newRequest("listFirewallRules", p.toURLValues()) - if err != nil { - return nil, err - } - - resp, err = convertFirewallServiceResponse(resp) - if err != nil { - return nil, err - } - - var r ListFirewallRulesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListFirewallRulesResponse struct { - Count int `json:"count"` - FirewallRules []*FirewallRule `json:"firewallrule"` -} - -type FirewallRule struct { - Cidrlist string `json:"cidrlist,omitempty"` - Endport int `json:"endport,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Ipaddressid string `json:"ipaddressid,omitempty"` - Networkid string `json:"networkid,omitempty"` - Protocol string `json:"protocol,omitempty"` - Startport int `json:"startport,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` -} - -type UpdateFirewallRuleParams struct { - p map[string]interface{} -} - -func (p *UpdateFirewallRuleParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["customid"]; found { - u.Set("customid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *UpdateFirewallRuleParams) SetCustomid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["customid"] = v - return -} - -func (p *UpdateFirewallRuleParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *UpdateFirewallRuleParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new UpdateFirewallRuleParams instance, -// as then you are sure you have configured all required params -func (s *FirewallService) NewUpdateFirewallRuleParams(id string) *UpdateFirewallRuleParams { - p := &UpdateFirewallRuleParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates firewall rule -func (s *FirewallService) UpdateFirewallRule(p *UpdateFirewallRuleParams) (*UpdateFirewallRuleResponse, error) { - resp, err := s.cs.newRequest("updateFirewallRule", p.toURLValues()) - if err != nil { - return nil, err - } - - resp, err = convertFirewallServiceResponse(resp) - if err != nil { - return nil, err - } - - var r UpdateFirewallRuleResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - b, err = convertFirewallServiceResponse(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateFirewallRuleResponse struct { - JobID string `json:"jobid,omitempty"` - Cidrlist string `json:"cidrlist,omitempty"` - Endport int `json:"endport,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Ipaddressid string `json:"ipaddressid,omitempty"` - Networkid string `json:"networkid,omitempty"` - Protocol string `json:"protocol,omitempty"` - Startport int `json:"startport,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` -} - -type CreateEgressFirewallRuleParams struct { - p map[string]interface{} -} - -func (p *CreateEgressFirewallRuleParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["cidrlist"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("cidrlist", vv) - } - if v, found := p.p["endport"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("endport", vv) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["icmpcode"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("icmpcode", vv) - } - if v, found := p.p["icmptype"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("icmptype", vv) - } - if v, found := p.p["networkid"]; found { - u.Set("networkid", v.(string)) - } - if v, found := p.p["protocol"]; found { - u.Set("protocol", v.(string)) - } - if v, found := p.p["startport"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("startport", vv) - } - if v, found := p.p["type"]; found { - u.Set("type", v.(string)) - } - return u -} - -func (p *CreateEgressFirewallRuleParams) SetCidrlist(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["cidrlist"] = v - return -} - -func (p *CreateEgressFirewallRuleParams) SetEndport(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["endport"] = v - return -} - -func (p *CreateEgressFirewallRuleParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *CreateEgressFirewallRuleParams) SetIcmpcode(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["icmpcode"] = v - return -} - -func (p *CreateEgressFirewallRuleParams) SetIcmptype(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["icmptype"] = v - return -} - -func (p *CreateEgressFirewallRuleParams) SetNetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkid"] = v - return -} - -func (p *CreateEgressFirewallRuleParams) SetProtocol(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["protocol"] = v - return -} - -func (p *CreateEgressFirewallRuleParams) SetStartport(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["startport"] = v - return -} - -func (p *CreateEgressFirewallRuleParams) SetType(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["firewallType"] = v - return -} - -// You should always use this function to get a new CreateEgressFirewallRuleParams instance, -// as then you are sure you have configured all required params -func (s *FirewallService) NewCreateEgressFirewallRuleParams(networkid string, protocol string) *CreateEgressFirewallRuleParams { - p := &CreateEgressFirewallRuleParams{} - p.p = make(map[string]interface{}) - p.p["networkid"] = networkid - p.p["protocol"] = protocol - return p -} - -// Creates a egress firewall rule for a given network -func (s *FirewallService) CreateEgressFirewallRule(p *CreateEgressFirewallRuleParams) (*CreateEgressFirewallRuleResponse, error) { - resp, err := s.cs.newRequest("createEgressFirewallRule", p.toURLValues()) - if err != nil { - return nil, err - } - - resp, err = convertFirewallServiceResponse(resp) - if err != nil { - return nil, err - } - - var r CreateEgressFirewallRuleResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - b, err = convertFirewallServiceResponse(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateEgressFirewallRuleResponse struct { - JobID string `json:"jobid,omitempty"` - Cidrlist string `json:"cidrlist,omitempty"` - Endport int `json:"endport,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Ipaddressid string `json:"ipaddressid,omitempty"` - Networkid string `json:"networkid,omitempty"` - Protocol string `json:"protocol,omitempty"` - Startport int `json:"startport,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` -} - -type DeleteEgressFirewallRuleParams struct { - p map[string]interface{} -} - -func (p *DeleteEgressFirewallRuleParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteEgressFirewallRuleParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteEgressFirewallRuleParams instance, -// as then you are sure you have configured all required params -func (s *FirewallService) NewDeleteEgressFirewallRuleParams(id string) *DeleteEgressFirewallRuleParams { - p := &DeleteEgressFirewallRuleParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes an egress firewall rule -func (s *FirewallService) DeleteEgressFirewallRule(p *DeleteEgressFirewallRuleParams) (*DeleteEgressFirewallRuleResponse, error) { - resp, err := s.cs.newRequest("deleteEgressFirewallRule", p.toURLValues()) - if err != nil { - return nil, err - } - - resp, err = convertFirewallServiceResponse(resp) - if err != nil { - return nil, err - } - - var r DeleteEgressFirewallRuleResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = convertFirewallServiceResponse(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteEgressFirewallRuleResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListEgressFirewallRulesParams struct { - p map[string]interface{} -} - -func (p *ListEgressFirewallRulesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["ipaddressid"]; found { - u.Set("ipaddressid", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["networkid"]; found { - u.Set("networkid", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["tags"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("tags[%d].key", i), k) - u.Set(fmt.Sprintf("tags[%d].value", i), vv) - i++ - } - } - return u -} - -func (p *ListEgressFirewallRulesParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListEgressFirewallRulesParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListEgressFirewallRulesParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *ListEgressFirewallRulesParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListEgressFirewallRulesParams) SetIpaddressid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ipaddressid"] = v - return -} - -func (p *ListEgressFirewallRulesParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListEgressFirewallRulesParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListEgressFirewallRulesParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListEgressFirewallRulesParams) SetNetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkid"] = v - return -} - -func (p *ListEgressFirewallRulesParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListEgressFirewallRulesParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListEgressFirewallRulesParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListEgressFirewallRulesParams) SetTags(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tags"] = v - return -} - -// You should always use this function to get a new ListEgressFirewallRulesParams instance, -// as then you are sure you have configured all required params -func (s *FirewallService) NewListEgressFirewallRulesParams() *ListEgressFirewallRulesParams { - p := &ListEgressFirewallRulesParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *FirewallService) GetEgressFirewallRuleByID(id string, opts ...OptionFunc) (*EgressFirewallRule, int, error) { - p := &ListEgressFirewallRulesParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListEgressFirewallRules(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.EgressFirewallRules[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for EgressFirewallRule UUID: %s!", id) -} - -// Lists all egress firewall rules for network ID. -func (s *FirewallService) ListEgressFirewallRules(p *ListEgressFirewallRulesParams) (*ListEgressFirewallRulesResponse, error) { - resp, err := s.cs.newRequest("listEgressFirewallRules", p.toURLValues()) - if err != nil { - return nil, err - } - - resp, err = convertFirewallServiceResponse(resp) - if err != nil { - return nil, err - } - - var r ListEgressFirewallRulesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListEgressFirewallRulesResponse struct { - Count int `json:"count"` - EgressFirewallRules []*EgressFirewallRule `json:"firewallrule"` -} - -type EgressFirewallRule struct { - Cidrlist string `json:"cidrlist,omitempty"` - Endport int `json:"endport,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Ipaddressid string `json:"ipaddressid,omitempty"` - Networkid string `json:"networkid,omitempty"` - Protocol string `json:"protocol,omitempty"` - Startport int `json:"startport,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` -} - -type UpdateEgressFirewallRuleParams struct { - p map[string]interface{} -} - -func (p *UpdateEgressFirewallRuleParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["customid"]; found { - u.Set("customid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *UpdateEgressFirewallRuleParams) SetCustomid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["customid"] = v - return -} - -func (p *UpdateEgressFirewallRuleParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *UpdateEgressFirewallRuleParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new UpdateEgressFirewallRuleParams instance, -// as then you are sure you have configured all required params -func (s *FirewallService) NewUpdateEgressFirewallRuleParams(id string) *UpdateEgressFirewallRuleParams { - p := &UpdateEgressFirewallRuleParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates egress firewall rule -func (s *FirewallService) UpdateEgressFirewallRule(p *UpdateEgressFirewallRuleParams) (*UpdateEgressFirewallRuleResponse, error) { - resp, err := s.cs.newRequest("updateEgressFirewallRule", p.toURLValues()) - if err != nil { - return nil, err - } - - resp, err = convertFirewallServiceResponse(resp) - if err != nil { - return nil, err - } - - var r UpdateEgressFirewallRuleResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - b, err = convertFirewallServiceResponse(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateEgressFirewallRuleResponse struct { - JobID string `json:"jobid,omitempty"` - Cidrlist string `json:"cidrlist,omitempty"` - Endport int `json:"endport,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Ipaddressid string `json:"ipaddressid,omitempty"` - Networkid string `json:"networkid,omitempty"` - Protocol string `json:"protocol,omitempty"` - Startport int `json:"startport,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` -} - -type AddPaloAltoFirewallParams struct { - p map[string]interface{} -} - -func (p *AddPaloAltoFirewallParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["networkdevicetype"]; found { - u.Set("networkdevicetype", v.(string)) - } - if v, found := p.p["password"]; found { - u.Set("password", v.(string)) - } - if v, found := p.p["physicalnetworkid"]; found { - u.Set("physicalnetworkid", v.(string)) - } - if v, found := p.p["url"]; found { - u.Set("url", v.(string)) - } - if v, found := p.p["username"]; found { - u.Set("username", v.(string)) - } - return u -} - -func (p *AddPaloAltoFirewallParams) SetNetworkdevicetype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkdevicetype"] = v - return -} - -func (p *AddPaloAltoFirewallParams) SetPassword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["password"] = v - return -} - -func (p *AddPaloAltoFirewallParams) SetPhysicalnetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["physicalnetworkid"] = v - return -} - -func (p *AddPaloAltoFirewallParams) SetUrl(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["url"] = v - return -} - -func (p *AddPaloAltoFirewallParams) SetUsername(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["username"] = v - return -} - -// You should always use this function to get a new AddPaloAltoFirewallParams instance, -// as then you are sure you have configured all required params -func (s *FirewallService) NewAddPaloAltoFirewallParams(networkdevicetype string, password string, physicalnetworkid string, url string, username string) *AddPaloAltoFirewallParams { - p := &AddPaloAltoFirewallParams{} - p.p = make(map[string]interface{}) - p.p["networkdevicetype"] = networkdevicetype - p.p["password"] = password - p.p["physicalnetworkid"] = physicalnetworkid - p.p["url"] = url - p.p["username"] = username - return p -} - -// Adds a Palo Alto firewall device -func (s *FirewallService) AddPaloAltoFirewall(p *AddPaloAltoFirewallParams) (*AddPaloAltoFirewallResponse, error) { - resp, err := s.cs.newRequest("addPaloAltoFirewall", p.toURLValues()) - if err != nil { - return nil, err - } - - resp, err = convertFirewallServiceResponse(resp) - if err != nil { - return nil, err - } - - var r AddPaloAltoFirewallResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - b, err = convertFirewallServiceResponse(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type AddPaloAltoFirewallResponse struct { - JobID string `json:"jobid,omitempty"` - Fwdevicecapacity int64 `json:"fwdevicecapacity,omitempty"` - Fwdeviceid string `json:"fwdeviceid,omitempty"` - Fwdevicename string `json:"fwdevicename,omitempty"` - Fwdevicestate string `json:"fwdevicestate,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Numretries string `json:"numretries,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Privateinterface string `json:"privateinterface,omitempty"` - Privatezone string `json:"privatezone,omitempty"` - Provider string `json:"provider,omitempty"` - Publicinterface string `json:"publicinterface,omitempty"` - Publiczone string `json:"publiczone,omitempty"` - Timeout string `json:"timeout,omitempty"` - Usageinterface string `json:"usageinterface,omitempty"` - Username string `json:"username,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type DeletePaloAltoFirewallParams struct { - p map[string]interface{} -} - -func (p *DeletePaloAltoFirewallParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["fwdeviceid"]; found { - u.Set("fwdeviceid", v.(string)) - } - return u -} - -func (p *DeletePaloAltoFirewallParams) SetFwdeviceid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fwdeviceid"] = v - return -} - -// You should always use this function to get a new DeletePaloAltoFirewallParams instance, -// as then you are sure you have configured all required params -func (s *FirewallService) NewDeletePaloAltoFirewallParams(fwdeviceid string) *DeletePaloAltoFirewallParams { - p := &DeletePaloAltoFirewallParams{} - p.p = make(map[string]interface{}) - p.p["fwdeviceid"] = fwdeviceid - return p -} - -// delete a Palo Alto firewall device -func (s *FirewallService) DeletePaloAltoFirewall(p *DeletePaloAltoFirewallParams) (*DeletePaloAltoFirewallResponse, error) { - resp, err := s.cs.newRequest("deletePaloAltoFirewall", p.toURLValues()) - if err != nil { - return nil, err - } - - resp, err = convertFirewallServiceResponse(resp) - if err != nil { - return nil, err - } - - var r DeletePaloAltoFirewallResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = convertFirewallServiceResponse(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeletePaloAltoFirewallResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ConfigurePaloAltoFirewallParams struct { - p map[string]interface{} -} - -func (p *ConfigurePaloAltoFirewallParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["fwdevicecapacity"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("fwdevicecapacity", vv) - } - if v, found := p.p["fwdeviceid"]; found { - u.Set("fwdeviceid", v.(string)) - } - return u -} - -func (p *ConfigurePaloAltoFirewallParams) SetFwdevicecapacity(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fwdevicecapacity"] = v - return -} - -func (p *ConfigurePaloAltoFirewallParams) SetFwdeviceid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fwdeviceid"] = v - return -} - -// You should always use this function to get a new ConfigurePaloAltoFirewallParams instance, -// as then you are sure you have configured all required params -func (s *FirewallService) NewConfigurePaloAltoFirewallParams(fwdeviceid string) *ConfigurePaloAltoFirewallParams { - p := &ConfigurePaloAltoFirewallParams{} - p.p = make(map[string]interface{}) - p.p["fwdeviceid"] = fwdeviceid - return p -} - -// Configures a Palo Alto firewall device -func (s *FirewallService) ConfigurePaloAltoFirewall(p *ConfigurePaloAltoFirewallParams) (*ConfigurePaloAltoFirewallResponse, error) { - resp, err := s.cs.newRequest("configurePaloAltoFirewall", p.toURLValues()) - if err != nil { - return nil, err - } - - resp, err = convertFirewallServiceResponse(resp) - if err != nil { - return nil, err - } - - var r ConfigurePaloAltoFirewallResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - b, err = convertFirewallServiceResponse(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type ConfigurePaloAltoFirewallResponse struct { - JobID string `json:"jobid,omitempty"` - Fwdevicecapacity int64 `json:"fwdevicecapacity,omitempty"` - Fwdeviceid string `json:"fwdeviceid,omitempty"` - Fwdevicename string `json:"fwdevicename,omitempty"` - Fwdevicestate string `json:"fwdevicestate,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Numretries string `json:"numretries,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Privateinterface string `json:"privateinterface,omitempty"` - Privatezone string `json:"privatezone,omitempty"` - Provider string `json:"provider,omitempty"` - Publicinterface string `json:"publicinterface,omitempty"` - Publiczone string `json:"publiczone,omitempty"` - Timeout string `json:"timeout,omitempty"` - Usageinterface string `json:"usageinterface,omitempty"` - Username string `json:"username,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type ListPaloAltoFirewallsParams struct { - p map[string]interface{} -} - -func (p *ListPaloAltoFirewallsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["fwdeviceid"]; found { - u.Set("fwdeviceid", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["physicalnetworkid"]; found { - u.Set("physicalnetworkid", v.(string)) - } - return u -} - -func (p *ListPaloAltoFirewallsParams) SetFwdeviceid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fwdeviceid"] = v - return -} - -func (p *ListPaloAltoFirewallsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListPaloAltoFirewallsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListPaloAltoFirewallsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListPaloAltoFirewallsParams) SetPhysicalnetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["physicalnetworkid"] = v - return -} - -// You should always use this function to get a new ListPaloAltoFirewallsParams instance, -// as then you are sure you have configured all required params -func (s *FirewallService) NewListPaloAltoFirewallsParams() *ListPaloAltoFirewallsParams { - p := &ListPaloAltoFirewallsParams{} - p.p = make(map[string]interface{}) - return p -} - -// lists Palo Alto firewall devices in a physical network -func (s *FirewallService) ListPaloAltoFirewalls(p *ListPaloAltoFirewallsParams) (*ListPaloAltoFirewallsResponse, error) { - resp, err := s.cs.newRequest("listPaloAltoFirewalls", p.toURLValues()) - if err != nil { - return nil, err - } - - resp, err = convertFirewallServiceResponse(resp) - if err != nil { - return nil, err - } - - var r ListPaloAltoFirewallsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListPaloAltoFirewallsResponse struct { - Count int `json:"count"` - PaloAltoFirewalls []*PaloAltoFirewall `json:"paloaltofirewall"` -} - -type PaloAltoFirewall struct { - Fwdevicecapacity int64 `json:"fwdevicecapacity,omitempty"` - Fwdeviceid string `json:"fwdeviceid,omitempty"` - Fwdevicename string `json:"fwdevicename,omitempty"` - Fwdevicestate string `json:"fwdevicestate,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Numretries string `json:"numretries,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Privateinterface string `json:"privateinterface,omitempty"` - Privatezone string `json:"privatezone,omitempty"` - Provider string `json:"provider,omitempty"` - Publicinterface string `json:"publicinterface,omitempty"` - Publiczone string `json:"publiczone,omitempty"` - Timeout string `json:"timeout,omitempty"` - Usageinterface string `json:"usageinterface,omitempty"` - Username string `json:"username,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/GuestOSService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/GuestOSService.go deleted file mode 100644 index 2f781004467..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/GuestOSService.go +++ /dev/null @@ -1,1046 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type ListOsTypesParams struct { - p map[string]interface{} -} - -func (p *ListOsTypesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["description"]; found { - u.Set("description", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["oscategoryid"]; found { - u.Set("oscategoryid", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - return u -} - -func (p *ListOsTypesParams) SetDescription(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["description"] = v - return -} - -func (p *ListOsTypesParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListOsTypesParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListOsTypesParams) SetOscategoryid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["oscategoryid"] = v - return -} - -func (p *ListOsTypesParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListOsTypesParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -// You should always use this function to get a new ListOsTypesParams instance, -// as then you are sure you have configured all required params -func (s *GuestOSService) NewListOsTypesParams() *ListOsTypesParams { - p := &ListOsTypesParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *GuestOSService) GetOsTypeByID(id string, opts ...OptionFunc) (*OsType, int, error) { - p := &ListOsTypesParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListOsTypes(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.OsTypes[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for OsType UUID: %s!", id) -} - -// Lists all supported OS types for this cloud. -func (s *GuestOSService) ListOsTypes(p *ListOsTypesParams) (*ListOsTypesResponse, error) { - resp, err := s.cs.newRequest("listOsTypes", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListOsTypesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListOsTypesResponse struct { - Count int `json:"count"` - OsTypes []*OsType `json:"ostype"` -} - -type OsType struct { - Description string `json:"description,omitempty"` - Id string `json:"id,omitempty"` - Isuserdefined string `json:"isuserdefined,omitempty"` - Oscategoryid string `json:"oscategoryid,omitempty"` -} - -type ListOsCategoriesParams struct { - p map[string]interface{} -} - -func (p *ListOsCategoriesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - return u -} - -func (p *ListOsCategoriesParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListOsCategoriesParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListOsCategoriesParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListOsCategoriesParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListOsCategoriesParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -// You should always use this function to get a new ListOsCategoriesParams instance, -// as then you are sure you have configured all required params -func (s *GuestOSService) NewListOsCategoriesParams() *ListOsCategoriesParams { - p := &ListOsCategoriesParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *GuestOSService) GetOsCategoryID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListOsCategoriesParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListOsCategories(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.OsCategories[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.OsCategories { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *GuestOSService) GetOsCategoryByName(name string, opts ...OptionFunc) (*OsCategory, int, error) { - id, count, err := s.GetOsCategoryID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetOsCategoryByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *GuestOSService) GetOsCategoryByID(id string, opts ...OptionFunc) (*OsCategory, int, error) { - p := &ListOsCategoriesParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListOsCategories(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.OsCategories[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for OsCategory UUID: %s!", id) -} - -// Lists all supported OS categories for this cloud. -func (s *GuestOSService) ListOsCategories(p *ListOsCategoriesParams) (*ListOsCategoriesResponse, error) { - resp, err := s.cs.newRequest("listOsCategories", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListOsCategoriesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListOsCategoriesResponse struct { - Count int `json:"count"` - OsCategories []*OsCategory `json:"oscategory"` -} - -type OsCategory struct { - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` -} - -type AddGuestOsParams struct { - p map[string]interface{} -} - -func (p *AddGuestOsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["oscategoryid"]; found { - u.Set("oscategoryid", v.(string)) - } - if v, found := p.p["osdisplayname"]; found { - u.Set("osdisplayname", v.(string)) - } - return u -} - -func (p *AddGuestOsParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *AddGuestOsParams) SetOscategoryid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["oscategoryid"] = v - return -} - -func (p *AddGuestOsParams) SetOsdisplayname(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["osdisplayname"] = v - return -} - -// You should always use this function to get a new AddGuestOsParams instance, -// as then you are sure you have configured all required params -func (s *GuestOSService) NewAddGuestOsParams(oscategoryid string, osdisplayname string) *AddGuestOsParams { - p := &AddGuestOsParams{} - p.p = make(map[string]interface{}) - p.p["oscategoryid"] = oscategoryid - p.p["osdisplayname"] = osdisplayname - return p -} - -// Add a new guest OS type -func (s *GuestOSService) AddGuestOs(p *AddGuestOsParams) (*AddGuestOsResponse, error) { - resp, err := s.cs.newRequest("addGuestOs", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AddGuestOsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type AddGuestOsResponse struct { - JobID string `json:"jobid,omitempty"` - Description string `json:"description,omitempty"` - Id string `json:"id,omitempty"` - Isuserdefined string `json:"isuserdefined,omitempty"` - Oscategoryid string `json:"oscategoryid,omitempty"` -} - -type UpdateGuestOsParams struct { - p map[string]interface{} -} - -func (p *UpdateGuestOsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["osdisplayname"]; found { - u.Set("osdisplayname", v.(string)) - } - return u -} - -func (p *UpdateGuestOsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateGuestOsParams) SetOsdisplayname(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["osdisplayname"] = v - return -} - -// You should always use this function to get a new UpdateGuestOsParams instance, -// as then you are sure you have configured all required params -func (s *GuestOSService) NewUpdateGuestOsParams(id string, osdisplayname string) *UpdateGuestOsParams { - p := &UpdateGuestOsParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - p.p["osdisplayname"] = osdisplayname - return p -} - -// Updates the information about Guest OS -func (s *GuestOSService) UpdateGuestOs(p *UpdateGuestOsParams) (*UpdateGuestOsResponse, error) { - resp, err := s.cs.newRequest("updateGuestOs", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateGuestOsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateGuestOsResponse struct { - JobID string `json:"jobid,omitempty"` - Description string `json:"description,omitempty"` - Id string `json:"id,omitempty"` - Isuserdefined string `json:"isuserdefined,omitempty"` - Oscategoryid string `json:"oscategoryid,omitempty"` -} - -type RemoveGuestOsParams struct { - p map[string]interface{} -} - -func (p *RemoveGuestOsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *RemoveGuestOsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new RemoveGuestOsParams instance, -// as then you are sure you have configured all required params -func (s *GuestOSService) NewRemoveGuestOsParams(id string) *RemoveGuestOsParams { - p := &RemoveGuestOsParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Removes a Guest OS from listing. -func (s *GuestOSService) RemoveGuestOs(p *RemoveGuestOsParams) (*RemoveGuestOsResponse, error) { - resp, err := s.cs.newRequest("removeGuestOs", p.toURLValues()) - if err != nil { - return nil, err - } - - var r RemoveGuestOsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type RemoveGuestOsResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListGuestOsMappingParams struct { - p map[string]interface{} -} - -func (p *ListGuestOsMappingParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["hypervisor"]; found { - u.Set("hypervisor", v.(string)) - } - if v, found := p.p["hypervisorversion"]; found { - u.Set("hypervisorversion", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["ostypeid"]; found { - u.Set("ostypeid", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - return u -} - -func (p *ListGuestOsMappingParams) SetHypervisor(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hypervisor"] = v - return -} - -func (p *ListGuestOsMappingParams) SetHypervisorversion(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hypervisorversion"] = v - return -} - -func (p *ListGuestOsMappingParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListGuestOsMappingParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListGuestOsMappingParams) SetOstypeid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ostypeid"] = v - return -} - -func (p *ListGuestOsMappingParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListGuestOsMappingParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -// You should always use this function to get a new ListGuestOsMappingParams instance, -// as then you are sure you have configured all required params -func (s *GuestOSService) NewListGuestOsMappingParams() *ListGuestOsMappingParams { - p := &ListGuestOsMappingParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *GuestOSService) GetGuestOsMappingByID(id string, opts ...OptionFunc) (*GuestOsMapping, int, error) { - p := &ListGuestOsMappingParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListGuestOsMapping(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.GuestOsMapping[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for GuestOsMapping UUID: %s!", id) -} - -// Lists all available OS mappings for given hypervisor -func (s *GuestOSService) ListGuestOsMapping(p *ListGuestOsMappingParams) (*ListGuestOsMappingResponse, error) { - resp, err := s.cs.newRequest("listGuestOsMapping", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListGuestOsMappingResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListGuestOsMappingResponse struct { - Count int `json:"count"` - GuestOsMapping []*GuestOsMapping `json:"guestosmapping"` -} - -type GuestOsMapping struct { - Hypervisor string `json:"hypervisor,omitempty"` - Hypervisorversion string `json:"hypervisorversion,omitempty"` - Id string `json:"id,omitempty"` - Isuserdefined string `json:"isuserdefined,omitempty"` - Osdisplayname string `json:"osdisplayname,omitempty"` - Osnameforhypervisor string `json:"osnameforhypervisor,omitempty"` - Ostypeid string `json:"ostypeid,omitempty"` -} - -type AddGuestOsMappingParams struct { - p map[string]interface{} -} - -func (p *AddGuestOsMappingParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["hypervisor"]; found { - u.Set("hypervisor", v.(string)) - } - if v, found := p.p["hypervisorversion"]; found { - u.Set("hypervisorversion", v.(string)) - } - if v, found := p.p["osdisplayname"]; found { - u.Set("osdisplayname", v.(string)) - } - if v, found := p.p["osnameforhypervisor"]; found { - u.Set("osnameforhypervisor", v.(string)) - } - if v, found := p.p["ostypeid"]; found { - u.Set("ostypeid", v.(string)) - } - return u -} - -func (p *AddGuestOsMappingParams) SetHypervisor(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hypervisor"] = v - return -} - -func (p *AddGuestOsMappingParams) SetHypervisorversion(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hypervisorversion"] = v - return -} - -func (p *AddGuestOsMappingParams) SetOsdisplayname(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["osdisplayname"] = v - return -} - -func (p *AddGuestOsMappingParams) SetOsnameforhypervisor(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["osnameforhypervisor"] = v - return -} - -func (p *AddGuestOsMappingParams) SetOstypeid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ostypeid"] = v - return -} - -// You should always use this function to get a new AddGuestOsMappingParams instance, -// as then you are sure you have configured all required params -func (s *GuestOSService) NewAddGuestOsMappingParams(hypervisor string, hypervisorversion string, osnameforhypervisor string) *AddGuestOsMappingParams { - p := &AddGuestOsMappingParams{} - p.p = make(map[string]interface{}) - p.p["hypervisor"] = hypervisor - p.p["hypervisorversion"] = hypervisorversion - p.p["osnameforhypervisor"] = osnameforhypervisor - return p -} - -// Adds a guest OS name to hypervisor OS name mapping -func (s *GuestOSService) AddGuestOsMapping(p *AddGuestOsMappingParams) (*AddGuestOsMappingResponse, error) { - resp, err := s.cs.newRequest("addGuestOsMapping", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AddGuestOsMappingResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type AddGuestOsMappingResponse struct { - JobID string `json:"jobid,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Hypervisorversion string `json:"hypervisorversion,omitempty"` - Id string `json:"id,omitempty"` - Isuserdefined string `json:"isuserdefined,omitempty"` - Osdisplayname string `json:"osdisplayname,omitempty"` - Osnameforhypervisor string `json:"osnameforhypervisor,omitempty"` - Ostypeid string `json:"ostypeid,omitempty"` -} - -type UpdateGuestOsMappingParams struct { - p map[string]interface{} -} - -func (p *UpdateGuestOsMappingParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["osnameforhypervisor"]; found { - u.Set("osnameforhypervisor", v.(string)) - } - return u -} - -func (p *UpdateGuestOsMappingParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateGuestOsMappingParams) SetOsnameforhypervisor(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["osnameforhypervisor"] = v - return -} - -// You should always use this function to get a new UpdateGuestOsMappingParams instance, -// as then you are sure you have configured all required params -func (s *GuestOSService) NewUpdateGuestOsMappingParams(id string, osnameforhypervisor string) *UpdateGuestOsMappingParams { - p := &UpdateGuestOsMappingParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - p.p["osnameforhypervisor"] = osnameforhypervisor - return p -} - -// Updates the information about Guest OS to Hypervisor specific name mapping -func (s *GuestOSService) UpdateGuestOsMapping(p *UpdateGuestOsMappingParams) (*UpdateGuestOsMappingResponse, error) { - resp, err := s.cs.newRequest("updateGuestOsMapping", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateGuestOsMappingResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateGuestOsMappingResponse struct { - JobID string `json:"jobid,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Hypervisorversion string `json:"hypervisorversion,omitempty"` - Id string `json:"id,omitempty"` - Isuserdefined string `json:"isuserdefined,omitempty"` - Osdisplayname string `json:"osdisplayname,omitempty"` - Osnameforhypervisor string `json:"osnameforhypervisor,omitempty"` - Ostypeid string `json:"ostypeid,omitempty"` -} - -type RemoveGuestOsMappingParams struct { - p map[string]interface{} -} - -func (p *RemoveGuestOsMappingParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *RemoveGuestOsMappingParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new RemoveGuestOsMappingParams instance, -// as then you are sure you have configured all required params -func (s *GuestOSService) NewRemoveGuestOsMappingParams(id string) *RemoveGuestOsMappingParams { - p := &RemoveGuestOsMappingParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Removes a Guest OS Mapping. -func (s *GuestOSService) RemoveGuestOsMapping(p *RemoveGuestOsMappingParams) (*RemoveGuestOsMappingResponse, error) { - resp, err := s.cs.newRequest("removeGuestOsMapping", p.toURLValues()) - if err != nil { - return nil, err - } - - var r RemoveGuestOsMappingResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type RemoveGuestOsMappingResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/HostService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/HostService.go deleted file mode 100644 index 66b3561bb2e..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/HostService.go +++ /dev/null @@ -1,2296 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type AddHostParams struct { - p map[string]interface{} -} - -func (p *AddHostParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["allocationstate"]; found { - u.Set("allocationstate", v.(string)) - } - if v, found := p.p["clusterid"]; found { - u.Set("clusterid", v.(string)) - } - if v, found := p.p["clustername"]; found { - u.Set("clustername", v.(string)) - } - if v, found := p.p["hosttags"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("hosttags", vv) - } - if v, found := p.p["hypervisor"]; found { - u.Set("hypervisor", v.(string)) - } - if v, found := p.p["password"]; found { - u.Set("password", v.(string)) - } - if v, found := p.p["podid"]; found { - u.Set("podid", v.(string)) - } - if v, found := p.p["url"]; found { - u.Set("url", v.(string)) - } - if v, found := p.p["username"]; found { - u.Set("username", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *AddHostParams) SetAllocationstate(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["allocationstate"] = v - return -} - -func (p *AddHostParams) SetClusterid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["clusterid"] = v - return -} - -func (p *AddHostParams) SetClustername(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["clustername"] = v - return -} - -func (p *AddHostParams) SetHosttags(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hosttags"] = v - return -} - -func (p *AddHostParams) SetHypervisor(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hypervisor"] = v - return -} - -func (p *AddHostParams) SetPassword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["password"] = v - return -} - -func (p *AddHostParams) SetPodid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["podid"] = v - return -} - -func (p *AddHostParams) SetUrl(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["url"] = v - return -} - -func (p *AddHostParams) SetUsername(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["username"] = v - return -} - -func (p *AddHostParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new AddHostParams instance, -// as then you are sure you have configured all required params -func (s *HostService) NewAddHostParams(hypervisor string, password string, podid string, url string, username string, zoneid string) *AddHostParams { - p := &AddHostParams{} - p.p = make(map[string]interface{}) - p.p["hypervisor"] = hypervisor - p.p["password"] = password - p.p["podid"] = podid - p.p["url"] = url - p.p["username"] = username - p.p["zoneid"] = zoneid - return p -} - -// Adds a new host. -func (s *HostService) AddHost(p *AddHostParams) (*AddHostResponse, error) { - resp, err := s.cs.newRequest("addHost", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AddHostResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type AddHostResponse struct { - Averageload int64 `json:"averageload,omitempty"` - Capabilities string `json:"capabilities,omitempty"` - Clusterid string `json:"clusterid,omitempty"` - Clustername string `json:"clustername,omitempty"` - Clustertype string `json:"clustertype,omitempty"` - Cpuallocated string `json:"cpuallocated,omitempty"` - Cpunumber int `json:"cpunumber,omitempty"` - Cpusockets int `json:"cpusockets,omitempty"` - Cpuspeed int64 `json:"cpuspeed,omitempty"` - Cpuused string `json:"cpuused,omitempty"` - Cpuwithoverprovisioning string `json:"cpuwithoverprovisioning,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Disconnected string `json:"disconnected,omitempty"` - Disksizeallocated int64 `json:"disksizeallocated,omitempty"` - Disksizetotal int64 `json:"disksizetotal,omitempty"` - Events string `json:"events,omitempty"` - Gpugroup []struct { - Gpugroupname string `json:"gpugroupname,omitempty"` - Vgpu []struct { - Maxcapacity int64 `json:"maxcapacity,omitempty"` - Maxheads int64 `json:"maxheads,omitempty"` - Maxresolutionx int64 `json:"maxresolutionx,omitempty"` - Maxresolutiony int64 `json:"maxresolutiony,omitempty"` - Maxvgpuperpgpu int64 `json:"maxvgpuperpgpu,omitempty"` - Remainingcapacity int64 `json:"remainingcapacity,omitempty"` - Vgputype string `json:"vgputype,omitempty"` - Videoram int64 `json:"videoram,omitempty"` - } `json:"vgpu,omitempty"` - } `json:"gpugroup,omitempty"` - Hahost bool `json:"hahost,omitempty"` - Hasenoughcapacity bool `json:"hasenoughcapacity,omitempty"` - Hosttags string `json:"hosttags,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Hypervisorversion string `json:"hypervisorversion,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Islocalstorageactive bool `json:"islocalstorageactive,omitempty"` - Lastpinged string `json:"lastpinged,omitempty"` - Managementserverid int64 `json:"managementserverid,omitempty"` - Memoryallocated int64 `json:"memoryallocated,omitempty"` - Memorytotal int64 `json:"memorytotal,omitempty"` - Memoryused int64 `json:"memoryused,omitempty"` - Name string `json:"name,omitempty"` - Networkkbsread int64 `json:"networkkbsread,omitempty"` - Networkkbswrite int64 `json:"networkkbswrite,omitempty"` - Oscategoryid string `json:"oscategoryid,omitempty"` - Oscategoryname string `json:"oscategoryname,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` - Removed string `json:"removed,omitempty"` - Resourcestate string `json:"resourcestate,omitempty"` - State string `json:"state,omitempty"` - Suitableformigration bool `json:"suitableformigration,omitempty"` - Type string `json:"type,omitempty"` - Version string `json:"version,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type ReconnectHostParams struct { - p map[string]interface{} -} - -func (p *ReconnectHostParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *ReconnectHostParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new ReconnectHostParams instance, -// as then you are sure you have configured all required params -func (s *HostService) NewReconnectHostParams(id string) *ReconnectHostParams { - p := &ReconnectHostParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Reconnects a host. -func (s *HostService) ReconnectHost(p *ReconnectHostParams) (*ReconnectHostResponse, error) { - resp, err := s.cs.newRequest("reconnectHost", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ReconnectHostResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type ReconnectHostResponse struct { - JobID string `json:"jobid,omitempty"` - Averageload int64 `json:"averageload,omitempty"` - Capabilities string `json:"capabilities,omitempty"` - Clusterid string `json:"clusterid,omitempty"` - Clustername string `json:"clustername,omitempty"` - Clustertype string `json:"clustertype,omitempty"` - Cpuallocated string `json:"cpuallocated,omitempty"` - Cpunumber int `json:"cpunumber,omitempty"` - Cpusockets int `json:"cpusockets,omitempty"` - Cpuspeed int64 `json:"cpuspeed,omitempty"` - Cpuused string `json:"cpuused,omitempty"` - Cpuwithoverprovisioning string `json:"cpuwithoverprovisioning,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Disconnected string `json:"disconnected,omitempty"` - Disksizeallocated int64 `json:"disksizeallocated,omitempty"` - Disksizetotal int64 `json:"disksizetotal,omitempty"` - Events string `json:"events,omitempty"` - Gpugroup []struct { - Gpugroupname string `json:"gpugroupname,omitempty"` - Vgpu []struct { - Maxcapacity int64 `json:"maxcapacity,omitempty"` - Maxheads int64 `json:"maxheads,omitempty"` - Maxresolutionx int64 `json:"maxresolutionx,omitempty"` - Maxresolutiony int64 `json:"maxresolutiony,omitempty"` - Maxvgpuperpgpu int64 `json:"maxvgpuperpgpu,omitempty"` - Remainingcapacity int64 `json:"remainingcapacity,omitempty"` - Vgputype string `json:"vgputype,omitempty"` - Videoram int64 `json:"videoram,omitempty"` - } `json:"vgpu,omitempty"` - } `json:"gpugroup,omitempty"` - Hahost bool `json:"hahost,omitempty"` - Hasenoughcapacity bool `json:"hasenoughcapacity,omitempty"` - Hosttags string `json:"hosttags,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Hypervisorversion string `json:"hypervisorversion,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Islocalstorageactive bool `json:"islocalstorageactive,omitempty"` - Lastpinged string `json:"lastpinged,omitempty"` - Managementserverid int64 `json:"managementserverid,omitempty"` - Memoryallocated int64 `json:"memoryallocated,omitempty"` - Memorytotal int64 `json:"memorytotal,omitempty"` - Memoryused int64 `json:"memoryused,omitempty"` - Name string `json:"name,omitempty"` - Networkkbsread int64 `json:"networkkbsread,omitempty"` - Networkkbswrite int64 `json:"networkkbswrite,omitempty"` - Oscategoryid string `json:"oscategoryid,omitempty"` - Oscategoryname string `json:"oscategoryname,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` - Removed string `json:"removed,omitempty"` - Resourcestate string `json:"resourcestate,omitempty"` - State string `json:"state,omitempty"` - Suitableformigration bool `json:"suitableformigration,omitempty"` - Type string `json:"type,omitempty"` - Version string `json:"version,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type UpdateHostParams struct { - p map[string]interface{} -} - -func (p *UpdateHostParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["allocationstate"]; found { - u.Set("allocationstate", v.(string)) - } - if v, found := p.p["hosttags"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("hosttags", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["oscategoryid"]; found { - u.Set("oscategoryid", v.(string)) - } - if v, found := p.p["url"]; found { - u.Set("url", v.(string)) - } - return u -} - -func (p *UpdateHostParams) SetAllocationstate(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["allocationstate"] = v - return -} - -func (p *UpdateHostParams) SetHosttags(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hosttags"] = v - return -} - -func (p *UpdateHostParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateHostParams) SetOscategoryid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["oscategoryid"] = v - return -} - -func (p *UpdateHostParams) SetUrl(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["url"] = v - return -} - -// You should always use this function to get a new UpdateHostParams instance, -// as then you are sure you have configured all required params -func (s *HostService) NewUpdateHostParams(id string) *UpdateHostParams { - p := &UpdateHostParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates a host. -func (s *HostService) UpdateHost(p *UpdateHostParams) (*UpdateHostResponse, error) { - resp, err := s.cs.newRequest("updateHost", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateHostResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type UpdateHostResponse struct { - Averageload int64 `json:"averageload,omitempty"` - Capabilities string `json:"capabilities,omitempty"` - Clusterid string `json:"clusterid,omitempty"` - Clustername string `json:"clustername,omitempty"` - Clustertype string `json:"clustertype,omitempty"` - Cpuallocated string `json:"cpuallocated,omitempty"` - Cpunumber int `json:"cpunumber,omitempty"` - Cpusockets int `json:"cpusockets,omitempty"` - Cpuspeed int64 `json:"cpuspeed,omitempty"` - Cpuused string `json:"cpuused,omitempty"` - Cpuwithoverprovisioning string `json:"cpuwithoverprovisioning,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Disconnected string `json:"disconnected,omitempty"` - Disksizeallocated int64 `json:"disksizeallocated,omitempty"` - Disksizetotal int64 `json:"disksizetotal,omitempty"` - Events string `json:"events,omitempty"` - Gpugroup []struct { - Gpugroupname string `json:"gpugroupname,omitempty"` - Vgpu []struct { - Maxcapacity int64 `json:"maxcapacity,omitempty"` - Maxheads int64 `json:"maxheads,omitempty"` - Maxresolutionx int64 `json:"maxresolutionx,omitempty"` - Maxresolutiony int64 `json:"maxresolutiony,omitempty"` - Maxvgpuperpgpu int64 `json:"maxvgpuperpgpu,omitempty"` - Remainingcapacity int64 `json:"remainingcapacity,omitempty"` - Vgputype string `json:"vgputype,omitempty"` - Videoram int64 `json:"videoram,omitempty"` - } `json:"vgpu,omitempty"` - } `json:"gpugroup,omitempty"` - Hahost bool `json:"hahost,omitempty"` - Hasenoughcapacity bool `json:"hasenoughcapacity,omitempty"` - Hosttags string `json:"hosttags,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Hypervisorversion string `json:"hypervisorversion,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Islocalstorageactive bool `json:"islocalstorageactive,omitempty"` - Lastpinged string `json:"lastpinged,omitempty"` - Managementserverid int64 `json:"managementserverid,omitempty"` - Memoryallocated int64 `json:"memoryallocated,omitempty"` - Memorytotal int64 `json:"memorytotal,omitempty"` - Memoryused int64 `json:"memoryused,omitempty"` - Name string `json:"name,omitempty"` - Networkkbsread int64 `json:"networkkbsread,omitempty"` - Networkkbswrite int64 `json:"networkkbswrite,omitempty"` - Oscategoryid string `json:"oscategoryid,omitempty"` - Oscategoryname string `json:"oscategoryname,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` - Removed string `json:"removed,omitempty"` - Resourcestate string `json:"resourcestate,omitempty"` - State string `json:"state,omitempty"` - Suitableformigration bool `json:"suitableformigration,omitempty"` - Type string `json:"type,omitempty"` - Version string `json:"version,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type DeleteHostParams struct { - p map[string]interface{} -} - -func (p *DeleteHostParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["forced"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("forced", vv) - } - if v, found := p.p["forcedestroylocalstorage"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("forcedestroylocalstorage", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteHostParams) SetForced(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["forced"] = v - return -} - -func (p *DeleteHostParams) SetForcedestroylocalstorage(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["forcedestroylocalstorage"] = v - return -} - -func (p *DeleteHostParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteHostParams instance, -// as then you are sure you have configured all required params -func (s *HostService) NewDeleteHostParams(id string) *DeleteHostParams { - p := &DeleteHostParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a host. -func (s *HostService) DeleteHost(p *DeleteHostParams) (*DeleteHostResponse, error) { - resp, err := s.cs.newRequest("deleteHost", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteHostResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type DeleteHostResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} - -type PrepareHostForMaintenanceParams struct { - p map[string]interface{} -} - -func (p *PrepareHostForMaintenanceParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *PrepareHostForMaintenanceParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new PrepareHostForMaintenanceParams instance, -// as then you are sure you have configured all required params -func (s *HostService) NewPrepareHostForMaintenanceParams(id string) *PrepareHostForMaintenanceParams { - p := &PrepareHostForMaintenanceParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Prepares a host for maintenance. -func (s *HostService) PrepareHostForMaintenance(p *PrepareHostForMaintenanceParams) (*PrepareHostForMaintenanceResponse, error) { - resp, err := s.cs.newRequest("prepareHostForMaintenance", p.toURLValues()) - if err != nil { - return nil, err - } - - var r PrepareHostForMaintenanceResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type PrepareHostForMaintenanceResponse struct { - JobID string `json:"jobid,omitempty"` - Averageload int64 `json:"averageload,omitempty"` - Capabilities string `json:"capabilities,omitempty"` - Clusterid string `json:"clusterid,omitempty"` - Clustername string `json:"clustername,omitempty"` - Clustertype string `json:"clustertype,omitempty"` - Cpuallocated string `json:"cpuallocated,omitempty"` - Cpunumber int `json:"cpunumber,omitempty"` - Cpusockets int `json:"cpusockets,omitempty"` - Cpuspeed int64 `json:"cpuspeed,omitempty"` - Cpuused string `json:"cpuused,omitempty"` - Cpuwithoverprovisioning string `json:"cpuwithoverprovisioning,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Disconnected string `json:"disconnected,omitempty"` - Disksizeallocated int64 `json:"disksizeallocated,omitempty"` - Disksizetotal int64 `json:"disksizetotal,omitempty"` - Events string `json:"events,omitempty"` - Gpugroup []struct { - Gpugroupname string `json:"gpugroupname,omitempty"` - Vgpu []struct { - Maxcapacity int64 `json:"maxcapacity,omitempty"` - Maxheads int64 `json:"maxheads,omitempty"` - Maxresolutionx int64 `json:"maxresolutionx,omitempty"` - Maxresolutiony int64 `json:"maxresolutiony,omitempty"` - Maxvgpuperpgpu int64 `json:"maxvgpuperpgpu,omitempty"` - Remainingcapacity int64 `json:"remainingcapacity,omitempty"` - Vgputype string `json:"vgputype,omitempty"` - Videoram int64 `json:"videoram,omitempty"` - } `json:"vgpu,omitempty"` - } `json:"gpugroup,omitempty"` - Hahost bool `json:"hahost,omitempty"` - Hasenoughcapacity bool `json:"hasenoughcapacity,omitempty"` - Hosttags string `json:"hosttags,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Hypervisorversion string `json:"hypervisorversion,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Islocalstorageactive bool `json:"islocalstorageactive,omitempty"` - Lastpinged string `json:"lastpinged,omitempty"` - Managementserverid int64 `json:"managementserverid,omitempty"` - Memoryallocated int64 `json:"memoryallocated,omitempty"` - Memorytotal int64 `json:"memorytotal,omitempty"` - Memoryused int64 `json:"memoryused,omitempty"` - Name string `json:"name,omitempty"` - Networkkbsread int64 `json:"networkkbsread,omitempty"` - Networkkbswrite int64 `json:"networkkbswrite,omitempty"` - Oscategoryid string `json:"oscategoryid,omitempty"` - Oscategoryname string `json:"oscategoryname,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` - Removed string `json:"removed,omitempty"` - Resourcestate string `json:"resourcestate,omitempty"` - State string `json:"state,omitempty"` - Suitableformigration bool `json:"suitableformigration,omitempty"` - Type string `json:"type,omitempty"` - Version string `json:"version,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type CancelHostMaintenanceParams struct { - p map[string]interface{} -} - -func (p *CancelHostMaintenanceParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *CancelHostMaintenanceParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new CancelHostMaintenanceParams instance, -// as then you are sure you have configured all required params -func (s *HostService) NewCancelHostMaintenanceParams(id string) *CancelHostMaintenanceParams { - p := &CancelHostMaintenanceParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Cancels host maintenance. -func (s *HostService) CancelHostMaintenance(p *CancelHostMaintenanceParams) (*CancelHostMaintenanceResponse, error) { - resp, err := s.cs.newRequest("cancelHostMaintenance", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CancelHostMaintenanceResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CancelHostMaintenanceResponse struct { - JobID string `json:"jobid,omitempty"` - Averageload int64 `json:"averageload,omitempty"` - Capabilities string `json:"capabilities,omitempty"` - Clusterid string `json:"clusterid,omitempty"` - Clustername string `json:"clustername,omitempty"` - Clustertype string `json:"clustertype,omitempty"` - Cpuallocated string `json:"cpuallocated,omitempty"` - Cpunumber int `json:"cpunumber,omitempty"` - Cpusockets int `json:"cpusockets,omitempty"` - Cpuspeed int64 `json:"cpuspeed,omitempty"` - Cpuused string `json:"cpuused,omitempty"` - Cpuwithoverprovisioning string `json:"cpuwithoverprovisioning,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Disconnected string `json:"disconnected,omitempty"` - Disksizeallocated int64 `json:"disksizeallocated,omitempty"` - Disksizetotal int64 `json:"disksizetotal,omitempty"` - Events string `json:"events,omitempty"` - Gpugroup []struct { - Gpugroupname string `json:"gpugroupname,omitempty"` - Vgpu []struct { - Maxcapacity int64 `json:"maxcapacity,omitempty"` - Maxheads int64 `json:"maxheads,omitempty"` - Maxresolutionx int64 `json:"maxresolutionx,omitempty"` - Maxresolutiony int64 `json:"maxresolutiony,omitempty"` - Maxvgpuperpgpu int64 `json:"maxvgpuperpgpu,omitempty"` - Remainingcapacity int64 `json:"remainingcapacity,omitempty"` - Vgputype string `json:"vgputype,omitempty"` - Videoram int64 `json:"videoram,omitempty"` - } `json:"vgpu,omitempty"` - } `json:"gpugroup,omitempty"` - Hahost bool `json:"hahost,omitempty"` - Hasenoughcapacity bool `json:"hasenoughcapacity,omitempty"` - Hosttags string `json:"hosttags,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Hypervisorversion string `json:"hypervisorversion,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Islocalstorageactive bool `json:"islocalstorageactive,omitempty"` - Lastpinged string `json:"lastpinged,omitempty"` - Managementserverid int64 `json:"managementserverid,omitempty"` - Memoryallocated int64 `json:"memoryallocated,omitempty"` - Memorytotal int64 `json:"memorytotal,omitempty"` - Memoryused int64 `json:"memoryused,omitempty"` - Name string `json:"name,omitempty"` - Networkkbsread int64 `json:"networkkbsread,omitempty"` - Networkkbswrite int64 `json:"networkkbswrite,omitempty"` - Oscategoryid string `json:"oscategoryid,omitempty"` - Oscategoryname string `json:"oscategoryname,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` - Removed string `json:"removed,omitempty"` - Resourcestate string `json:"resourcestate,omitempty"` - State string `json:"state,omitempty"` - Suitableformigration bool `json:"suitableformigration,omitempty"` - Type string `json:"type,omitempty"` - Version string `json:"version,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type ListHostsParams struct { - p map[string]interface{} -} - -func (p *ListHostsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["clusterid"]; found { - u.Set("clusterid", v.(string)) - } - if v, found := p.p["details"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("details", vv) - } - if v, found := p.p["hahost"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("hahost", vv) - } - if v, found := p.p["hypervisor"]; found { - u.Set("hypervisor", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["podid"]; found { - u.Set("podid", v.(string)) - } - if v, found := p.p["resourcestate"]; found { - u.Set("resourcestate", v.(string)) - } - if v, found := p.p["state"]; found { - u.Set("state", v.(string)) - } - if v, found := p.p["type"]; found { - u.Set("type", v.(string)) - } - if v, found := p.p["virtualmachineid"]; found { - u.Set("virtualmachineid", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ListHostsParams) SetClusterid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["clusterid"] = v - return -} - -func (p *ListHostsParams) SetDetails(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["details"] = v - return -} - -func (p *ListHostsParams) SetHahost(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hahost"] = v - return -} - -func (p *ListHostsParams) SetHypervisor(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hypervisor"] = v - return -} - -func (p *ListHostsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListHostsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListHostsParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListHostsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListHostsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListHostsParams) SetPodid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["podid"] = v - return -} - -func (p *ListHostsParams) SetResourcestate(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["resourcestate"] = v - return -} - -func (p *ListHostsParams) SetState(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["state"] = v - return -} - -func (p *ListHostsParams) SetType(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hostType"] = v - return -} - -func (p *ListHostsParams) SetVirtualmachineid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["virtualmachineid"] = v - return -} - -func (p *ListHostsParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ListHostsParams instance, -// as then you are sure you have configured all required params -func (s *HostService) NewListHostsParams() *ListHostsParams { - p := &ListHostsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *HostService) GetHostID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListHostsParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListHosts(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.Hosts[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.Hosts { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *HostService) GetHostByName(name string, opts ...OptionFunc) (*Host, int, error) { - id, count, err := s.GetHostID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetHostByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *HostService) GetHostByID(id string, opts ...OptionFunc) (*Host, int, error) { - p := &ListHostsParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListHosts(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.Hosts[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for Host UUID: %s!", id) -} - -// Lists hosts. -func (s *HostService) ListHosts(p *ListHostsParams) (*ListHostsResponse, error) { - resp, err := s.cs.newRequest("listHosts", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListHostsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListHostsResponse struct { - Count int `json:"count"` - Hosts []*Host `json:"host"` -} - -type Host struct { - Averageload int64 `json:"averageload,omitempty"` - Capabilities string `json:"capabilities,omitempty"` - Clusterid string `json:"clusterid,omitempty"` - Clustername string `json:"clustername,omitempty"` - Clustertype string `json:"clustertype,omitempty"` - Cpuallocated string `json:"cpuallocated,omitempty"` - Cpunumber int `json:"cpunumber,omitempty"` - Cpusockets int `json:"cpusockets,omitempty"` - Cpuspeed int64 `json:"cpuspeed,omitempty"` - Cpuused string `json:"cpuused,omitempty"` - Cpuwithoverprovisioning string `json:"cpuwithoverprovisioning,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Disconnected string `json:"disconnected,omitempty"` - Disksizeallocated int64 `json:"disksizeallocated,omitempty"` - Disksizetotal int64 `json:"disksizetotal,omitempty"` - Events string `json:"events,omitempty"` - Gpugroup []struct { - Gpugroupname string `json:"gpugroupname,omitempty"` - Vgpu []struct { - Maxcapacity int64 `json:"maxcapacity,omitempty"` - Maxheads int64 `json:"maxheads,omitempty"` - Maxresolutionx int64 `json:"maxresolutionx,omitempty"` - Maxresolutiony int64 `json:"maxresolutiony,omitempty"` - Maxvgpuperpgpu int64 `json:"maxvgpuperpgpu,omitempty"` - Remainingcapacity int64 `json:"remainingcapacity,omitempty"` - Vgputype string `json:"vgputype,omitempty"` - Videoram int64 `json:"videoram,omitempty"` - } `json:"vgpu,omitempty"` - } `json:"gpugroup,omitempty"` - Hahost bool `json:"hahost,omitempty"` - Hasenoughcapacity bool `json:"hasenoughcapacity,omitempty"` - Hosttags string `json:"hosttags,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Hypervisorversion string `json:"hypervisorversion,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Islocalstorageactive bool `json:"islocalstorageactive,omitempty"` - Lastpinged string `json:"lastpinged,omitempty"` - Managementserverid int64 `json:"managementserverid,omitempty"` - Memoryallocated int64 `json:"memoryallocated,omitempty"` - Memorytotal int64 `json:"memorytotal,omitempty"` - Memoryused int64 `json:"memoryused,omitempty"` - Name string `json:"name,omitempty"` - Networkkbsread int64 `json:"networkkbsread,omitempty"` - Networkkbswrite int64 `json:"networkkbswrite,omitempty"` - Oscategoryid string `json:"oscategoryid,omitempty"` - Oscategoryname string `json:"oscategoryname,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` - Removed string `json:"removed,omitempty"` - Resourcestate string `json:"resourcestate,omitempty"` - State string `json:"state,omitempty"` - Suitableformigration bool `json:"suitableformigration,omitempty"` - Type string `json:"type,omitempty"` - Version string `json:"version,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type ListHostTagsParams struct { - p map[string]interface{} -} - -func (p *ListHostTagsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - return u -} - -func (p *ListHostTagsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListHostTagsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListHostTagsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -// You should always use this function to get a new ListHostTagsParams instance, -// as then you are sure you have configured all required params -func (s *HostService) NewListHostTagsParams() *ListHostTagsParams { - p := &ListHostTagsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *HostService) GetHostTagID(keyword string, opts ...OptionFunc) (string, int, error) { - p := &ListHostTagsParams{} - p.p = make(map[string]interface{}) - - p.p["keyword"] = keyword - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListHostTags(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", keyword, l) - } - - if l.Count == 1 { - return l.HostTags[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.HostTags { - if v.Name == keyword { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l) -} - -// Lists host tags -func (s *HostService) ListHostTags(p *ListHostTagsParams) (*ListHostTagsResponse, error) { - resp, err := s.cs.newRequest("listHostTags", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListHostTagsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListHostTagsResponse struct { - Count int `json:"count"` - HostTags []*HostTag `json:"hosttag"` -} - -type HostTag struct { - Hostid int64 `json:"hostid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` -} - -type FindHostsForMigrationParams struct { - p map[string]interface{} -} - -func (p *FindHostsForMigrationParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["virtualmachineid"]; found { - u.Set("virtualmachineid", v.(string)) - } - return u -} - -func (p *FindHostsForMigrationParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *FindHostsForMigrationParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *FindHostsForMigrationParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *FindHostsForMigrationParams) SetVirtualmachineid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["virtualmachineid"] = v - return -} - -// You should always use this function to get a new FindHostsForMigrationParams instance, -// as then you are sure you have configured all required params -func (s *HostService) NewFindHostsForMigrationParams(virtualmachineid string) *FindHostsForMigrationParams { - p := &FindHostsForMigrationParams{} - p.p = make(map[string]interface{}) - p.p["virtualmachineid"] = virtualmachineid - return p -} - -// Find hosts suitable for migrating a virtual machine. -func (s *HostService) FindHostsForMigration(p *FindHostsForMigrationParams) (*FindHostsForMigrationResponse, error) { - resp, err := s.cs.newRequest("findHostsForMigration", p.toURLValues()) - if err != nil { - return nil, err - } - - var r FindHostsForMigrationResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type FindHostsForMigrationResponse struct { - Averageload int64 `json:"averageload,omitempty"` - Capabilities string `json:"capabilities,omitempty"` - Clusterid string `json:"clusterid,omitempty"` - Clustername string `json:"clustername,omitempty"` - Clustertype string `json:"clustertype,omitempty"` - Cpuallocated string `json:"cpuallocated,omitempty"` - Cpunumber int `json:"cpunumber,omitempty"` - Cpuspeed int64 `json:"cpuspeed,omitempty"` - Cpuused string `json:"cpuused,omitempty"` - Cpuwithoverprovisioning string `json:"cpuwithoverprovisioning,omitempty"` - Created string `json:"created,omitempty"` - Disconnected string `json:"disconnected,omitempty"` - Disksizeallocated int64 `json:"disksizeallocated,omitempty"` - Disksizetotal int64 `json:"disksizetotal,omitempty"` - Events string `json:"events,omitempty"` - Hahost bool `json:"hahost,omitempty"` - Hasenoughcapacity bool `json:"hasenoughcapacity,omitempty"` - Hosttags string `json:"hosttags,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Hypervisorversion string `json:"hypervisorversion,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Islocalstorageactive bool `json:"islocalstorageactive,omitempty"` - Lastpinged string `json:"lastpinged,omitempty"` - Managementserverid int64 `json:"managementserverid,omitempty"` - Memoryallocated int64 `json:"memoryallocated,omitempty"` - Memorytotal int64 `json:"memorytotal,omitempty"` - Memoryused int64 `json:"memoryused,omitempty"` - Name string `json:"name,omitempty"` - Networkkbsread int64 `json:"networkkbsread,omitempty"` - Networkkbswrite int64 `json:"networkkbswrite,omitempty"` - Oscategoryid string `json:"oscategoryid,omitempty"` - Oscategoryname string `json:"oscategoryname,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` - Removed string `json:"removed,omitempty"` - RequiresStorageMotion bool `json:"requiresStorageMotion,omitempty"` - Resourcestate string `json:"resourcestate,omitempty"` - State string `json:"state,omitempty"` - Suitableformigration bool `json:"suitableformigration,omitempty"` - Type string `json:"type,omitempty"` - Version string `json:"version,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type AddSecondaryStorageParams struct { - p map[string]interface{} -} - -func (p *AddSecondaryStorageParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["url"]; found { - u.Set("url", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *AddSecondaryStorageParams) SetUrl(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["url"] = v - return -} - -func (p *AddSecondaryStorageParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new AddSecondaryStorageParams instance, -// as then you are sure you have configured all required params -func (s *HostService) NewAddSecondaryStorageParams(url string) *AddSecondaryStorageParams { - p := &AddSecondaryStorageParams{} - p.p = make(map[string]interface{}) - p.p["url"] = url - return p -} - -// Adds secondary storage. -func (s *HostService) AddSecondaryStorage(p *AddSecondaryStorageParams) (*AddSecondaryStorageResponse, error) { - resp, err := s.cs.newRequest("addSecondaryStorage", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AddSecondaryStorageResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type AddSecondaryStorageResponse struct { - Details []string `json:"details,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Protocol string `json:"protocol,omitempty"` - Providername string `json:"providername,omitempty"` - Scope string `json:"scope,omitempty"` - Url string `json:"url,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type UpdateHostPasswordParams struct { - p map[string]interface{} -} - -func (p *UpdateHostPasswordParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["clusterid"]; found { - u.Set("clusterid", v.(string)) - } - if v, found := p.p["hostid"]; found { - u.Set("hostid", v.(string)) - } - if v, found := p.p["password"]; found { - u.Set("password", v.(string)) - } - if v, found := p.p["update_passwd_on_host"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("update_passwd_on_host", vv) - } - if v, found := p.p["username"]; found { - u.Set("username", v.(string)) - } - return u -} - -func (p *UpdateHostPasswordParams) SetClusterid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["clusterid"] = v - return -} - -func (p *UpdateHostPasswordParams) SetHostid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hostid"] = v - return -} - -func (p *UpdateHostPasswordParams) SetPassword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["password"] = v - return -} - -func (p *UpdateHostPasswordParams) SetUpdate_passwd_on_host(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["update_passwd_on_host"] = v - return -} - -func (p *UpdateHostPasswordParams) SetUsername(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["username"] = v - return -} - -// You should always use this function to get a new UpdateHostPasswordParams instance, -// as then you are sure you have configured all required params -func (s *HostService) NewUpdateHostPasswordParams(password string, username string) *UpdateHostPasswordParams { - p := &UpdateHostPasswordParams{} - p.p = make(map[string]interface{}) - p.p["password"] = password - p.p["username"] = username - return p -} - -// Update password of a host/pool on management server. -func (s *HostService) UpdateHostPassword(p *UpdateHostPasswordParams) (*UpdateHostPasswordResponse, error) { - resp, err := s.cs.newRequest("updateHostPassword", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateHostPasswordResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type UpdateHostPasswordResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} - -type ReleaseHostReservationParams struct { - p map[string]interface{} -} - -func (p *ReleaseHostReservationParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *ReleaseHostReservationParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new ReleaseHostReservationParams instance, -// as then you are sure you have configured all required params -func (s *HostService) NewReleaseHostReservationParams(id string) *ReleaseHostReservationParams { - p := &ReleaseHostReservationParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Releases host reservation. -func (s *HostService) ReleaseHostReservation(p *ReleaseHostReservationParams) (*ReleaseHostReservationResponse, error) { - resp, err := s.cs.newRequest("releaseHostReservation", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ReleaseHostReservationResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type ReleaseHostReservationResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type AddBaremetalHostParams struct { - p map[string]interface{} -} - -func (p *AddBaremetalHostParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["allocationstate"]; found { - u.Set("allocationstate", v.(string)) - } - if v, found := p.p["clusterid"]; found { - u.Set("clusterid", v.(string)) - } - if v, found := p.p["clustername"]; found { - u.Set("clustername", v.(string)) - } - if v, found := p.p["hosttags"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("hosttags", vv) - } - if v, found := p.p["hypervisor"]; found { - u.Set("hypervisor", v.(string)) - } - if v, found := p.p["ipaddress"]; found { - u.Set("ipaddress", v.(string)) - } - if v, found := p.p["password"]; found { - u.Set("password", v.(string)) - } - if v, found := p.p["podid"]; found { - u.Set("podid", v.(string)) - } - if v, found := p.p["url"]; found { - u.Set("url", v.(string)) - } - if v, found := p.p["username"]; found { - u.Set("username", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *AddBaremetalHostParams) SetAllocationstate(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["allocationstate"] = v - return -} - -func (p *AddBaremetalHostParams) SetClusterid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["clusterid"] = v - return -} - -func (p *AddBaremetalHostParams) SetClustername(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["clustername"] = v - return -} - -func (p *AddBaremetalHostParams) SetHosttags(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hosttags"] = v - return -} - -func (p *AddBaremetalHostParams) SetHypervisor(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hypervisor"] = v - return -} - -func (p *AddBaremetalHostParams) SetIpaddress(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ipaddress"] = v - return -} - -func (p *AddBaremetalHostParams) SetPassword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["password"] = v - return -} - -func (p *AddBaremetalHostParams) SetPodid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["podid"] = v - return -} - -func (p *AddBaremetalHostParams) SetUrl(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["url"] = v - return -} - -func (p *AddBaremetalHostParams) SetUsername(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["username"] = v - return -} - -func (p *AddBaremetalHostParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new AddBaremetalHostParams instance, -// as then you are sure you have configured all required params -func (s *HostService) NewAddBaremetalHostParams(hypervisor string, password string, podid string, url string, username string, zoneid string) *AddBaremetalHostParams { - p := &AddBaremetalHostParams{} - p.p = make(map[string]interface{}) - p.p["hypervisor"] = hypervisor - p.p["password"] = password - p.p["podid"] = podid - p.p["url"] = url - p.p["username"] = username - p.p["zoneid"] = zoneid - return p -} - -// add a baremetal host -func (s *HostService) AddBaremetalHost(p *AddBaremetalHostParams) (*AddBaremetalHostResponse, error) { - resp, err := s.cs.newRequest("addBaremetalHost", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AddBaremetalHostResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type AddBaremetalHostResponse struct { - Averageload int64 `json:"averageload,omitempty"` - Capabilities string `json:"capabilities,omitempty"` - Clusterid string `json:"clusterid,omitempty"` - Clustername string `json:"clustername,omitempty"` - Clustertype string `json:"clustertype,omitempty"` - Cpuallocated string `json:"cpuallocated,omitempty"` - Cpunumber int `json:"cpunumber,omitempty"` - Cpusockets int `json:"cpusockets,omitempty"` - Cpuspeed int64 `json:"cpuspeed,omitempty"` - Cpuused string `json:"cpuused,omitempty"` - Cpuwithoverprovisioning string `json:"cpuwithoverprovisioning,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Disconnected string `json:"disconnected,omitempty"` - Disksizeallocated int64 `json:"disksizeallocated,omitempty"` - Disksizetotal int64 `json:"disksizetotal,omitempty"` - Events string `json:"events,omitempty"` - Gpugroup []struct { - Gpugroupname string `json:"gpugroupname,omitempty"` - Vgpu []struct { - Maxcapacity int64 `json:"maxcapacity,omitempty"` - Maxheads int64 `json:"maxheads,omitempty"` - Maxresolutionx int64 `json:"maxresolutionx,omitempty"` - Maxresolutiony int64 `json:"maxresolutiony,omitempty"` - Maxvgpuperpgpu int64 `json:"maxvgpuperpgpu,omitempty"` - Remainingcapacity int64 `json:"remainingcapacity,omitempty"` - Vgputype string `json:"vgputype,omitempty"` - Videoram int64 `json:"videoram,omitempty"` - } `json:"vgpu,omitempty"` - } `json:"gpugroup,omitempty"` - Hahost bool `json:"hahost,omitempty"` - Hasenoughcapacity bool `json:"hasenoughcapacity,omitempty"` - Hosttags string `json:"hosttags,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Hypervisorversion string `json:"hypervisorversion,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Islocalstorageactive bool `json:"islocalstorageactive,omitempty"` - Lastpinged string `json:"lastpinged,omitempty"` - Managementserverid int64 `json:"managementserverid,omitempty"` - Memoryallocated int64 `json:"memoryallocated,omitempty"` - Memorytotal int64 `json:"memorytotal,omitempty"` - Memoryused int64 `json:"memoryused,omitempty"` - Name string `json:"name,omitempty"` - Networkkbsread int64 `json:"networkkbsread,omitempty"` - Networkkbswrite int64 `json:"networkkbswrite,omitempty"` - Oscategoryid string `json:"oscategoryid,omitempty"` - Oscategoryname string `json:"oscategoryname,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` - Removed string `json:"removed,omitempty"` - Resourcestate string `json:"resourcestate,omitempty"` - State string `json:"state,omitempty"` - Suitableformigration bool `json:"suitableformigration,omitempty"` - Type string `json:"type,omitempty"` - Version string `json:"version,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type DedicateHostParams struct { - p map[string]interface{} -} - -func (p *DedicateHostParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["hostid"]; found { - u.Set("hostid", v.(string)) - } - return u -} - -func (p *DedicateHostParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *DedicateHostParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *DedicateHostParams) SetHostid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hostid"] = v - return -} - -// You should always use this function to get a new DedicateHostParams instance, -// as then you are sure you have configured all required params -func (s *HostService) NewDedicateHostParams(domainid string, hostid string) *DedicateHostParams { - p := &DedicateHostParams{} - p.p = make(map[string]interface{}) - p.p["domainid"] = domainid - p.p["hostid"] = hostid - return p -} - -// Dedicates a host. -func (s *HostService) DedicateHost(p *DedicateHostParams) (*DedicateHostResponse, error) { - resp, err := s.cs.newRequest("dedicateHost", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DedicateHostResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DedicateHostResponse struct { - JobID string `json:"jobid,omitempty"` - Accountid string `json:"accountid,omitempty"` - Affinitygroupid string `json:"affinitygroupid,omitempty"` - Domainid string `json:"domainid,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Id string `json:"id,omitempty"` -} - -type ReleaseDedicatedHostParams struct { - p map[string]interface{} -} - -func (p *ReleaseDedicatedHostParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["hostid"]; found { - u.Set("hostid", v.(string)) - } - return u -} - -func (p *ReleaseDedicatedHostParams) SetHostid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hostid"] = v - return -} - -// You should always use this function to get a new ReleaseDedicatedHostParams instance, -// as then you are sure you have configured all required params -func (s *HostService) NewReleaseDedicatedHostParams(hostid string) *ReleaseDedicatedHostParams { - p := &ReleaseDedicatedHostParams{} - p.p = make(map[string]interface{}) - p.p["hostid"] = hostid - return p -} - -// Release the dedication for host -func (s *HostService) ReleaseDedicatedHost(p *ReleaseDedicatedHostParams) (*ReleaseDedicatedHostResponse, error) { - resp, err := s.cs.newRequest("releaseDedicatedHost", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ReleaseDedicatedHostResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type ReleaseDedicatedHostResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListDedicatedHostsParams struct { - p map[string]interface{} -} - -func (p *ListDedicatedHostsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["affinitygroupid"]; found { - u.Set("affinitygroupid", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["hostid"]; found { - u.Set("hostid", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - return u -} - -func (p *ListDedicatedHostsParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListDedicatedHostsParams) SetAffinitygroupid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["affinitygroupid"] = v - return -} - -func (p *ListDedicatedHostsParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListDedicatedHostsParams) SetHostid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hostid"] = v - return -} - -func (p *ListDedicatedHostsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListDedicatedHostsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListDedicatedHostsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -// You should always use this function to get a new ListDedicatedHostsParams instance, -// as then you are sure you have configured all required params -func (s *HostService) NewListDedicatedHostsParams() *ListDedicatedHostsParams { - p := &ListDedicatedHostsParams{} - p.p = make(map[string]interface{}) - return p -} - -// Lists dedicated hosts. -func (s *HostService) ListDedicatedHosts(p *ListDedicatedHostsParams) (*ListDedicatedHostsResponse, error) { - resp, err := s.cs.newRequest("listDedicatedHosts", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListDedicatedHostsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListDedicatedHostsResponse struct { - Count int `json:"count"` - DedicatedHosts []*DedicatedHost `json:"dedicatedhost"` -} - -type DedicatedHost struct { - Accountid string `json:"accountid,omitempty"` - Affinitygroupid string `json:"affinitygroupid,omitempty"` - Domainid string `json:"domainid,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Id string `json:"id,omitempty"` -} - -type AddGloboDnsHostParams struct { - p map[string]interface{} -} - -func (p *AddGloboDnsHostParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["password"]; found { - u.Set("password", v.(string)) - } - if v, found := p.p["physicalnetworkid"]; found { - u.Set("physicalnetworkid", v.(string)) - } - if v, found := p.p["url"]; found { - u.Set("url", v.(string)) - } - if v, found := p.p["username"]; found { - u.Set("username", v.(string)) - } - return u -} - -func (p *AddGloboDnsHostParams) SetPassword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["password"] = v - return -} - -func (p *AddGloboDnsHostParams) SetPhysicalnetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["physicalnetworkid"] = v - return -} - -func (p *AddGloboDnsHostParams) SetUrl(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["url"] = v - return -} - -func (p *AddGloboDnsHostParams) SetUsername(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["username"] = v - return -} - -// You should always use this function to get a new AddGloboDnsHostParams instance, -// as then you are sure you have configured all required params -func (s *HostService) NewAddGloboDnsHostParams(password string, physicalnetworkid string, url string, username string) *AddGloboDnsHostParams { - p := &AddGloboDnsHostParams{} - p.p = make(map[string]interface{}) - p.p["password"] = password - p.p["physicalnetworkid"] = physicalnetworkid - p.p["url"] = url - p.p["username"] = username - return p -} - -// Adds the GloboDNS external host -func (s *HostService) AddGloboDnsHost(p *AddGloboDnsHostParams) (*AddGloboDnsHostResponse, error) { - resp, err := s.cs.newRequest("addGloboDnsHost", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AddGloboDnsHostResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type AddGloboDnsHostResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/HypervisorService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/HypervisorService.go deleted file mode 100644 index c172615c987..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/HypervisorService.go +++ /dev/null @@ -1,299 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type ListHypervisorsParams struct { - p map[string]interface{} -} - -func (p *ListHypervisorsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ListHypervisorsParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ListHypervisorsParams instance, -// as then you are sure you have configured all required params -func (s *HypervisorService) NewListHypervisorsParams() *ListHypervisorsParams { - p := &ListHypervisorsParams{} - p.p = make(map[string]interface{}) - return p -} - -// List hypervisors -func (s *HypervisorService) ListHypervisors(p *ListHypervisorsParams) (*ListHypervisorsResponse, error) { - resp, err := s.cs.newRequest("listHypervisors", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListHypervisorsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListHypervisorsResponse struct { - Count int `json:"count"` - Hypervisors []*Hypervisor `json:"hypervisor"` -} - -type Hypervisor struct { - Name string `json:"name,omitempty"` -} - -type UpdateHypervisorCapabilitiesParams struct { - p map[string]interface{} -} - -func (p *UpdateHypervisorCapabilitiesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["maxguestslimit"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("maxguestslimit", vv) - } - if v, found := p.p["securitygroupenabled"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("securitygroupenabled", vv) - } - return u -} - -func (p *UpdateHypervisorCapabilitiesParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateHypervisorCapabilitiesParams) SetMaxguestslimit(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["maxguestslimit"] = v - return -} - -func (p *UpdateHypervisorCapabilitiesParams) SetSecuritygroupenabled(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["securitygroupenabled"] = v - return -} - -// You should always use this function to get a new UpdateHypervisorCapabilitiesParams instance, -// as then you are sure you have configured all required params -func (s *HypervisorService) NewUpdateHypervisorCapabilitiesParams() *UpdateHypervisorCapabilitiesParams { - p := &UpdateHypervisorCapabilitiesParams{} - p.p = make(map[string]interface{}) - return p -} - -// Updates a hypervisor capabilities. -func (s *HypervisorService) UpdateHypervisorCapabilities(p *UpdateHypervisorCapabilitiesParams) (*UpdateHypervisorCapabilitiesResponse, error) { - resp, err := s.cs.newRequest("updateHypervisorCapabilities", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateHypervisorCapabilitiesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type UpdateHypervisorCapabilitiesResponse struct { - Hypervisor string `json:"hypervisor,omitempty"` - Hypervisorversion string `json:"hypervisorversion,omitempty"` - Id string `json:"id,omitempty"` - Maxdatavolumeslimit int `json:"maxdatavolumeslimit,omitempty"` - Maxguestslimit int64 `json:"maxguestslimit,omitempty"` - Maxhostspercluster int `json:"maxhostspercluster,omitempty"` - Securitygroupenabled bool `json:"securitygroupenabled,omitempty"` - Storagemotionenabled bool `json:"storagemotionenabled,omitempty"` -} - -type ListHypervisorCapabilitiesParams struct { - p map[string]interface{} -} - -func (p *ListHypervisorCapabilitiesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["hypervisor"]; found { - u.Set("hypervisor", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - return u -} - -func (p *ListHypervisorCapabilitiesParams) SetHypervisor(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hypervisor"] = v - return -} - -func (p *ListHypervisorCapabilitiesParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListHypervisorCapabilitiesParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListHypervisorCapabilitiesParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListHypervisorCapabilitiesParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -// You should always use this function to get a new ListHypervisorCapabilitiesParams instance, -// as then you are sure you have configured all required params -func (s *HypervisorService) NewListHypervisorCapabilitiesParams() *ListHypervisorCapabilitiesParams { - p := &ListHypervisorCapabilitiesParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *HypervisorService) GetHypervisorCapabilityByID(id string, opts ...OptionFunc) (*HypervisorCapability, int, error) { - p := &ListHypervisorCapabilitiesParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListHypervisorCapabilities(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.HypervisorCapabilities[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for HypervisorCapability UUID: %s!", id) -} - -// Lists all hypervisor capabilities. -func (s *HypervisorService) ListHypervisorCapabilities(p *ListHypervisorCapabilitiesParams) (*ListHypervisorCapabilitiesResponse, error) { - resp, err := s.cs.newRequest("listHypervisorCapabilities", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListHypervisorCapabilitiesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListHypervisorCapabilitiesResponse struct { - Count int `json:"count"` - HypervisorCapabilities []*HypervisorCapability `json:"hypervisorcapability"` -} - -type HypervisorCapability struct { - Hypervisor string `json:"hypervisor,omitempty"` - Hypervisorversion string `json:"hypervisorversion,omitempty"` - Id string `json:"id,omitempty"` - Maxdatavolumeslimit int `json:"maxdatavolumeslimit,omitempty"` - Maxguestslimit int64 `json:"maxguestslimit,omitempty"` - Maxhostspercluster int `json:"maxhostspercluster,omitempty"` - Securitygroupenabled bool `json:"securitygroupenabled,omitempty"` - Storagemotionenabled bool `json:"storagemotionenabled,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/ISOService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/ISOService.go deleted file mode 100644 index a4ad582a673..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/ISOService.go +++ /dev/null @@ -1,1944 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type AttachIsoParams struct { - p map[string]interface{} -} - -func (p *AttachIsoParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["virtualmachineid"]; found { - u.Set("virtualmachineid", v.(string)) - } - return u -} - -func (p *AttachIsoParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *AttachIsoParams) SetVirtualmachineid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["virtualmachineid"] = v - return -} - -// You should always use this function to get a new AttachIsoParams instance, -// as then you are sure you have configured all required params -func (s *ISOService) NewAttachIsoParams(id string, virtualmachineid string) *AttachIsoParams { - p := &AttachIsoParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - p.p["virtualmachineid"] = virtualmachineid - return p -} - -// Attaches an ISO to a virtual machine. -func (s *ISOService) AttachIso(p *AttachIsoParams) (*AttachIsoResponse, error) { - resp, err := s.cs.newRequest("attachIso", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AttachIsoResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type AttachIsoResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Affinitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Type string `json:"type,omitempty"` - VirtualmachineIds []string `json:"virtualmachineIds,omitempty"` - } `json:"affinitygroup,omitempty"` - Cpunumber int `json:"cpunumber,omitempty"` - Cpuspeed int `json:"cpuspeed,omitempty"` - Cpuused string `json:"cpuused,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Diskioread int64 `json:"diskioread,omitempty"` - Diskiowrite int64 `json:"diskiowrite,omitempty"` - Diskkbsread int64 `json:"diskkbsread,omitempty"` - Diskkbswrite int64 `json:"diskkbswrite,omitempty"` - Diskofferingid string `json:"diskofferingid,omitempty"` - Diskofferingname string `json:"diskofferingname,omitempty"` - Displayname string `json:"displayname,omitempty"` - Displayvm bool `json:"displayvm,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"` - Group string `json:"group,omitempty"` - Groupid string `json:"groupid,omitempty"` - Guestosid string `json:"guestosid,omitempty"` - Haenable bool `json:"haenable,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Instancename string `json:"instancename,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isodisplaytext string `json:"isodisplaytext,omitempty"` - Isoid string `json:"isoid,omitempty"` - Isoname string `json:"isoname,omitempty"` - Keypair string `json:"keypair,omitempty"` - Memory int `json:"memory,omitempty"` - Name string `json:"name,omitempty"` - Networkkbsread int64 `json:"networkkbsread,omitempty"` - Networkkbswrite int64 `json:"networkkbswrite,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Ostypeid int64 `json:"ostypeid,omitempty"` - Password string `json:"password,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - Rootdeviceid int64 `json:"rootdeviceid,omitempty"` - Rootdevicetype string `json:"rootdevicetype,omitempty"` - Securitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Egressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"egressrule,omitempty"` - Id string `json:"id,omitempty"` - Ingressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"ingressrule,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinecount int `json:"virtualmachinecount,omitempty"` - Virtualmachineids []string `json:"virtualmachineids,omitempty"` - } `json:"securitygroup,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - Servicestate string `json:"servicestate,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatedisplaytext string `json:"templatedisplaytext,omitempty"` - Templateid string `json:"templateid,omitempty"` - Templatename string `json:"templatename,omitempty"` - Userid string `json:"userid,omitempty"` - Username string `json:"username,omitempty"` - Vgpu string `json:"vgpu,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type DetachIsoParams struct { - p map[string]interface{} -} - -func (p *DetachIsoParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["virtualmachineid"]; found { - u.Set("virtualmachineid", v.(string)) - } - return u -} - -func (p *DetachIsoParams) SetVirtualmachineid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["virtualmachineid"] = v - return -} - -// You should always use this function to get a new DetachIsoParams instance, -// as then you are sure you have configured all required params -func (s *ISOService) NewDetachIsoParams(virtualmachineid string) *DetachIsoParams { - p := &DetachIsoParams{} - p.p = make(map[string]interface{}) - p.p["virtualmachineid"] = virtualmachineid - return p -} - -// Detaches any ISO file (if any) currently attached to a virtual machine. -func (s *ISOService) DetachIso(p *DetachIsoParams) (*DetachIsoResponse, error) { - resp, err := s.cs.newRequest("detachIso", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DetachIsoResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DetachIsoResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Affinitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Type string `json:"type,omitempty"` - VirtualmachineIds []string `json:"virtualmachineIds,omitempty"` - } `json:"affinitygroup,omitempty"` - Cpunumber int `json:"cpunumber,omitempty"` - Cpuspeed int `json:"cpuspeed,omitempty"` - Cpuused string `json:"cpuused,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Diskioread int64 `json:"diskioread,omitempty"` - Diskiowrite int64 `json:"diskiowrite,omitempty"` - Diskkbsread int64 `json:"diskkbsread,omitempty"` - Diskkbswrite int64 `json:"diskkbswrite,omitempty"` - Diskofferingid string `json:"diskofferingid,omitempty"` - Diskofferingname string `json:"diskofferingname,omitempty"` - Displayname string `json:"displayname,omitempty"` - Displayvm bool `json:"displayvm,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"` - Group string `json:"group,omitempty"` - Groupid string `json:"groupid,omitempty"` - Guestosid string `json:"guestosid,omitempty"` - Haenable bool `json:"haenable,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Instancename string `json:"instancename,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isodisplaytext string `json:"isodisplaytext,omitempty"` - Isoid string `json:"isoid,omitempty"` - Isoname string `json:"isoname,omitempty"` - Keypair string `json:"keypair,omitempty"` - Memory int `json:"memory,omitempty"` - Name string `json:"name,omitempty"` - Networkkbsread int64 `json:"networkkbsread,omitempty"` - Networkkbswrite int64 `json:"networkkbswrite,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Ostypeid int64 `json:"ostypeid,omitempty"` - Password string `json:"password,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - Rootdeviceid int64 `json:"rootdeviceid,omitempty"` - Rootdevicetype string `json:"rootdevicetype,omitempty"` - Securitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Egressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"egressrule,omitempty"` - Id string `json:"id,omitempty"` - Ingressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"ingressrule,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinecount int `json:"virtualmachinecount,omitempty"` - Virtualmachineids []string `json:"virtualmachineids,omitempty"` - } `json:"securitygroup,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - Servicestate string `json:"servicestate,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatedisplaytext string `json:"templatedisplaytext,omitempty"` - Templateid string `json:"templateid,omitempty"` - Templatename string `json:"templatename,omitempty"` - Userid string `json:"userid,omitempty"` - Username string `json:"username,omitempty"` - Vgpu string `json:"vgpu,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type ListIsosParams struct { - p map[string]interface{} -} - -func (p *ListIsosParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["bootable"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("bootable", vv) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["hypervisor"]; found { - u.Set("hypervisor", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isofilter"]; found { - u.Set("isofilter", v.(string)) - } - if v, found := p.p["ispublic"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("ispublic", vv) - } - if v, found := p.p["isready"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isready", vv) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["showremoved"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("showremoved", vv) - } - if v, found := p.p["tags"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("tags[%d].key", i), k) - u.Set(fmt.Sprintf("tags[%d].value", i), vv) - i++ - } - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ListIsosParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListIsosParams) SetBootable(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["bootable"] = v - return -} - -func (p *ListIsosParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListIsosParams) SetHypervisor(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hypervisor"] = v - return -} - -func (p *ListIsosParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListIsosParams) SetIsofilter(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isofilter"] = v - return -} - -func (p *ListIsosParams) SetIspublic(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ispublic"] = v - return -} - -func (p *ListIsosParams) SetIsready(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isready"] = v - return -} - -func (p *ListIsosParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListIsosParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListIsosParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListIsosParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListIsosParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListIsosParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListIsosParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListIsosParams) SetShowremoved(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["showremoved"] = v - return -} - -func (p *ListIsosParams) SetTags(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tags"] = v - return -} - -func (p *ListIsosParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ListIsosParams instance, -// as then you are sure you have configured all required params -func (s *ISOService) NewListIsosParams() *ListIsosParams { - p := &ListIsosParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *ISOService) GetIsoID(name string, isofilter string, zoneid string, opts ...OptionFunc) (string, int, error) { - p := &ListIsosParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - p.p["isofilter"] = isofilter - p.p["zoneid"] = zoneid - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListIsos(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.Isos[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.Isos { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *ISOService) GetIsoByName(name string, isofilter string, zoneid string, opts ...OptionFunc) (*Iso, int, error) { - id, count, err := s.GetIsoID(name, isofilter, zoneid, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetIsoByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *ISOService) GetIsoByID(id string, opts ...OptionFunc) (*Iso, int, error) { - p := &ListIsosParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListIsos(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.Isos[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for Iso UUID: %s!", id) -} - -// Lists all available ISO files. -func (s *ISOService) ListIsos(p *ListIsosParams) (*ListIsosResponse, error) { - resp, err := s.cs.newRequest("listIsos", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListIsosResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListIsosResponse struct { - Count int `json:"count"` - Isos []*Iso `json:"iso"` -} - -type Iso struct { - Account string `json:"account,omitempty"` - Accountid string `json:"accountid,omitempty"` - Bootable bool `json:"bootable,omitempty"` - Checksum string `json:"checksum,omitempty"` - Created string `json:"created,omitempty"` - CrossZones bool `json:"crossZones,omitempty"` - Details map[string]string `json:"details,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Format string `json:"format,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isextractable bool `json:"isextractable,omitempty"` - Isfeatured bool `json:"isfeatured,omitempty"` - Ispublic bool `json:"ispublic,omitempty"` - Isready bool `json:"isready,omitempty"` - Name string `json:"name,omitempty"` - Ostypeid string `json:"ostypeid,omitempty"` - Ostypename string `json:"ostypename,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Removed string `json:"removed,omitempty"` - Size int64 `json:"size,omitempty"` - Sourcetemplateid string `json:"sourcetemplateid,omitempty"` - Sshkeyenabled bool `json:"sshkeyenabled,omitempty"` - Status string `json:"status,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatetag string `json:"templatetag,omitempty"` - Templatetype string `json:"templatetype,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type RegisterIsoParams struct { - p map[string]interface{} -} - -func (p *RegisterIsoParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["bootable"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("bootable", vv) - } - if v, found := p.p["checksum"]; found { - u.Set("checksum", v.(string)) - } - if v, found := p.p["displaytext"]; found { - u.Set("displaytext", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["imagestoreuuid"]; found { - u.Set("imagestoreuuid", v.(string)) - } - if v, found := p.p["isdynamicallyscalable"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isdynamicallyscalable", vv) - } - if v, found := p.p["isextractable"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isextractable", vv) - } - if v, found := p.p["isfeatured"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isfeatured", vv) - } - if v, found := p.p["ispublic"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("ispublic", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["ostypeid"]; found { - u.Set("ostypeid", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["url"]; found { - u.Set("url", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *RegisterIsoParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *RegisterIsoParams) SetBootable(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["bootable"] = v - return -} - -func (p *RegisterIsoParams) SetChecksum(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["checksum"] = v - return -} - -func (p *RegisterIsoParams) SetDisplaytext(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displaytext"] = v - return -} - -func (p *RegisterIsoParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *RegisterIsoParams) SetImagestoreuuid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["imagestoreuuid"] = v - return -} - -func (p *RegisterIsoParams) SetIsdynamicallyscalable(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isdynamicallyscalable"] = v - return -} - -func (p *RegisterIsoParams) SetIsextractable(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isextractable"] = v - return -} - -func (p *RegisterIsoParams) SetIsfeatured(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isfeatured"] = v - return -} - -func (p *RegisterIsoParams) SetIspublic(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ispublic"] = v - return -} - -func (p *RegisterIsoParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *RegisterIsoParams) SetOstypeid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ostypeid"] = v - return -} - -func (p *RegisterIsoParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *RegisterIsoParams) SetUrl(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["url"] = v - return -} - -func (p *RegisterIsoParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new RegisterIsoParams instance, -// as then you are sure you have configured all required params -func (s *ISOService) NewRegisterIsoParams(displaytext string, name string, url string, zoneid string) *RegisterIsoParams { - p := &RegisterIsoParams{} - p.p = make(map[string]interface{}) - p.p["displaytext"] = displaytext - p.p["name"] = name - p.p["url"] = url - p.p["zoneid"] = zoneid - return p -} - -// Registers an existing ISO into the CloudStack Cloud. -func (s *ISOService) RegisterIso(p *RegisterIsoParams) (*RegisterIsoResponse, error) { - resp, err := s.cs.newRequest("registerIso", p.toURLValues()) - if err != nil { - return nil, err - } - - var r RegisterIsoResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type RegisterIsoResponse struct { - Account string `json:"account,omitempty"` - Accountid string `json:"accountid,omitempty"` - Bootable bool `json:"bootable,omitempty"` - Checksum string `json:"checksum,omitempty"` - Created string `json:"created,omitempty"` - CrossZones bool `json:"crossZones,omitempty"` - Details map[string]string `json:"details,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Format string `json:"format,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isextractable bool `json:"isextractable,omitempty"` - Isfeatured bool `json:"isfeatured,omitempty"` - Ispublic bool `json:"ispublic,omitempty"` - Isready bool `json:"isready,omitempty"` - Name string `json:"name,omitempty"` - Ostypeid string `json:"ostypeid,omitempty"` - Ostypename string `json:"ostypename,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Removed string `json:"removed,omitempty"` - Size int64 `json:"size,omitempty"` - Sourcetemplateid string `json:"sourcetemplateid,omitempty"` - Sshkeyenabled bool `json:"sshkeyenabled,omitempty"` - Status string `json:"status,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatetag string `json:"templatetag,omitempty"` - Templatetype string `json:"templatetype,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type UpdateIsoParams struct { - p map[string]interface{} -} - -func (p *UpdateIsoParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["bootable"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("bootable", vv) - } - if v, found := p.p["details"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("details[%d].key", i), k) - u.Set(fmt.Sprintf("details[%d].value", i), vv) - i++ - } - } - if v, found := p.p["displaytext"]; found { - u.Set("displaytext", v.(string)) - } - if v, found := p.p["format"]; found { - u.Set("format", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isdynamicallyscalable"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isdynamicallyscalable", vv) - } - if v, found := p.p["isrouting"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrouting", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["ostypeid"]; found { - u.Set("ostypeid", v.(string)) - } - if v, found := p.p["passwordenabled"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("passwordenabled", vv) - } - if v, found := p.p["requireshvm"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("requireshvm", vv) - } - if v, found := p.p["sortkey"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("sortkey", vv) - } - return u -} - -func (p *UpdateIsoParams) SetBootable(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["bootable"] = v - return -} - -func (p *UpdateIsoParams) SetDetails(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["details"] = v - return -} - -func (p *UpdateIsoParams) SetDisplaytext(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displaytext"] = v - return -} - -func (p *UpdateIsoParams) SetFormat(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["format"] = v - return -} - -func (p *UpdateIsoParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateIsoParams) SetIsdynamicallyscalable(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isdynamicallyscalable"] = v - return -} - -func (p *UpdateIsoParams) SetIsrouting(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrouting"] = v - return -} - -func (p *UpdateIsoParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *UpdateIsoParams) SetOstypeid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ostypeid"] = v - return -} - -func (p *UpdateIsoParams) SetPasswordenabled(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["passwordenabled"] = v - return -} - -func (p *UpdateIsoParams) SetRequireshvm(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["requireshvm"] = v - return -} - -func (p *UpdateIsoParams) SetSortkey(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["sortkey"] = v - return -} - -// You should always use this function to get a new UpdateIsoParams instance, -// as then you are sure you have configured all required params -func (s *ISOService) NewUpdateIsoParams(id string) *UpdateIsoParams { - p := &UpdateIsoParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates an ISO file. -func (s *ISOService) UpdateIso(p *UpdateIsoParams) (*UpdateIsoResponse, error) { - resp, err := s.cs.newRequest("updateIso", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateIsoResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type UpdateIsoResponse struct { - Account string `json:"account,omitempty"` - Accountid string `json:"accountid,omitempty"` - Bootable bool `json:"bootable,omitempty"` - Checksum string `json:"checksum,omitempty"` - Created string `json:"created,omitempty"` - CrossZones bool `json:"crossZones,omitempty"` - Details map[string]string `json:"details,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Format string `json:"format,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isextractable bool `json:"isextractable,omitempty"` - Isfeatured bool `json:"isfeatured,omitempty"` - Ispublic bool `json:"ispublic,omitempty"` - Isready bool `json:"isready,omitempty"` - Name string `json:"name,omitempty"` - Ostypeid string `json:"ostypeid,omitempty"` - Ostypename string `json:"ostypename,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Removed string `json:"removed,omitempty"` - Size int64 `json:"size,omitempty"` - Sourcetemplateid string `json:"sourcetemplateid,omitempty"` - Sshkeyenabled bool `json:"sshkeyenabled,omitempty"` - Status string `json:"status,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatetag string `json:"templatetag,omitempty"` - Templatetype string `json:"templatetype,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type DeleteIsoParams struct { - p map[string]interface{} -} - -func (p *DeleteIsoParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *DeleteIsoParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *DeleteIsoParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new DeleteIsoParams instance, -// as then you are sure you have configured all required params -func (s *ISOService) NewDeleteIsoParams(id string) *DeleteIsoParams { - p := &DeleteIsoParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes an ISO file. -func (s *ISOService) DeleteIso(p *DeleteIsoParams) (*DeleteIsoResponse, error) { - resp, err := s.cs.newRequest("deleteIso", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteIsoResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteIsoResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type CopyIsoParams struct { - p map[string]interface{} -} - -func (p *CopyIsoParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["destzoneid"]; found { - u.Set("destzoneid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["sourcezoneid"]; found { - u.Set("sourcezoneid", v.(string)) - } - return u -} - -func (p *CopyIsoParams) SetDestzoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["destzoneid"] = v - return -} - -func (p *CopyIsoParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *CopyIsoParams) SetSourcezoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["sourcezoneid"] = v - return -} - -// You should always use this function to get a new CopyIsoParams instance, -// as then you are sure you have configured all required params -func (s *ISOService) NewCopyIsoParams(destzoneid string, id string) *CopyIsoParams { - p := &CopyIsoParams{} - p.p = make(map[string]interface{}) - p.p["destzoneid"] = destzoneid - p.p["id"] = id - return p -} - -// Copies an ISO from one zone to another. -func (s *ISOService) CopyIso(p *CopyIsoParams) (*CopyIsoResponse, error) { - resp, err := s.cs.newRequest("copyIso", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CopyIsoResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CopyIsoResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Accountid string `json:"accountid,omitempty"` - Bootable bool `json:"bootable,omitempty"` - Checksum string `json:"checksum,omitempty"` - Created string `json:"created,omitempty"` - CrossZones bool `json:"crossZones,omitempty"` - Details map[string]string `json:"details,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Format string `json:"format,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isextractable bool `json:"isextractable,omitempty"` - Isfeatured bool `json:"isfeatured,omitempty"` - Ispublic bool `json:"ispublic,omitempty"` - Isready bool `json:"isready,omitempty"` - Name string `json:"name,omitempty"` - Ostypeid string `json:"ostypeid,omitempty"` - Ostypename string `json:"ostypename,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Removed string `json:"removed,omitempty"` - Size int64 `json:"size,omitempty"` - Sourcetemplateid string `json:"sourcetemplateid,omitempty"` - Sshkeyenabled bool `json:"sshkeyenabled,omitempty"` - Status string `json:"status,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatetag string `json:"templatetag,omitempty"` - Templatetype string `json:"templatetype,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type UpdateIsoPermissionsParams struct { - p map[string]interface{} -} - -func (p *UpdateIsoPermissionsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["accounts"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("accounts", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isextractable"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isextractable", vv) - } - if v, found := p.p["isfeatured"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isfeatured", vv) - } - if v, found := p.p["ispublic"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("ispublic", vv) - } - if v, found := p.p["op"]; found { - u.Set("op", v.(string)) - } - if v, found := p.p["projectids"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("projectids", vv) - } - return u -} - -func (p *UpdateIsoPermissionsParams) SetAccounts(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["accounts"] = v - return -} - -func (p *UpdateIsoPermissionsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateIsoPermissionsParams) SetIsextractable(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isextractable"] = v - return -} - -func (p *UpdateIsoPermissionsParams) SetIsfeatured(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isfeatured"] = v - return -} - -func (p *UpdateIsoPermissionsParams) SetIspublic(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ispublic"] = v - return -} - -func (p *UpdateIsoPermissionsParams) SetOp(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["op"] = v - return -} - -func (p *UpdateIsoPermissionsParams) SetProjectids(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectids"] = v - return -} - -// You should always use this function to get a new UpdateIsoPermissionsParams instance, -// as then you are sure you have configured all required params -func (s *ISOService) NewUpdateIsoPermissionsParams(id string) *UpdateIsoPermissionsParams { - p := &UpdateIsoPermissionsParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates ISO permissions -func (s *ISOService) UpdateIsoPermissions(p *UpdateIsoPermissionsParams) (*UpdateIsoPermissionsResponse, error) { - resp, err := s.cs.newRequest("updateIsoPermissions", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateIsoPermissionsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type UpdateIsoPermissionsResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} - -type ListIsoPermissionsParams struct { - p map[string]interface{} -} - -func (p *ListIsoPermissionsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *ListIsoPermissionsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new ListIsoPermissionsParams instance, -// as then you are sure you have configured all required params -func (s *ISOService) NewListIsoPermissionsParams(id string) *ListIsoPermissionsParams { - p := &ListIsoPermissionsParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *ISOService) GetIsoPermissionByID(id string, opts ...OptionFunc) (*IsoPermission, int, error) { - p := &ListIsoPermissionsParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListIsoPermissions(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.IsoPermissions[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for IsoPermission UUID: %s!", id) -} - -// List iso visibility and all accounts that have permissions to view this iso. -func (s *ISOService) ListIsoPermissions(p *ListIsoPermissionsParams) (*ListIsoPermissionsResponse, error) { - resp, err := s.cs.newRequest("listIsoPermissions", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListIsoPermissionsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListIsoPermissionsResponse struct { - Count int `json:"count"` - IsoPermissions []*IsoPermission `json:"isopermission"` -} - -type IsoPermission struct { - Account []string `json:"account,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Ispublic bool `json:"ispublic,omitempty"` - Projectids []string `json:"projectids,omitempty"` -} - -type ExtractIsoParams struct { - p map[string]interface{} -} - -func (p *ExtractIsoParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["mode"]; found { - u.Set("mode", v.(string)) - } - if v, found := p.p["url"]; found { - u.Set("url", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ExtractIsoParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ExtractIsoParams) SetMode(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["mode"] = v - return -} - -func (p *ExtractIsoParams) SetUrl(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["url"] = v - return -} - -func (p *ExtractIsoParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ExtractIsoParams instance, -// as then you are sure you have configured all required params -func (s *ISOService) NewExtractIsoParams(id string, mode string) *ExtractIsoParams { - p := &ExtractIsoParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - p.p["mode"] = mode - return p -} - -// Extracts an ISO -func (s *ISOService) ExtractIso(p *ExtractIsoParams) (*ExtractIsoResponse, error) { - resp, err := s.cs.newRequest("extractIso", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ExtractIsoResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type ExtractIsoResponse struct { - JobID string `json:"jobid,omitempty"` - Accountid string `json:"accountid,omitempty"` - Created string `json:"created,omitempty"` - ExtractId string `json:"extractId,omitempty"` - ExtractMode string `json:"extractMode,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Resultstring string `json:"resultstring,omitempty"` - State string `json:"state,omitempty"` - Status string `json:"status,omitempty"` - Storagetype string `json:"storagetype,omitempty"` - Uploadpercentage int `json:"uploadpercentage,omitempty"` - Url string `json:"url,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/ImageStoreService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/ImageStoreService.go deleted file mode 100644 index 58fce6e825a..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/ImageStoreService.go +++ /dev/null @@ -1,1062 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type AddImageStoreParams struct { - p map[string]interface{} -} - -func (p *AddImageStoreParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["details"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("details[%d].key", i), k) - u.Set(fmt.Sprintf("details[%d].value", i), vv) - i++ - } - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["provider"]; found { - u.Set("provider", v.(string)) - } - if v, found := p.p["url"]; found { - u.Set("url", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *AddImageStoreParams) SetDetails(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["details"] = v - return -} - -func (p *AddImageStoreParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *AddImageStoreParams) SetProvider(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["provider"] = v - return -} - -func (p *AddImageStoreParams) SetUrl(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["url"] = v - return -} - -func (p *AddImageStoreParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new AddImageStoreParams instance, -// as then you are sure you have configured all required params -func (s *ImageStoreService) NewAddImageStoreParams(provider string) *AddImageStoreParams { - p := &AddImageStoreParams{} - p.p = make(map[string]interface{}) - p.p["provider"] = provider - return p -} - -// Adds backup image store. -func (s *ImageStoreService) AddImageStore(p *AddImageStoreParams) (*AddImageStoreResponse, error) { - resp, err := s.cs.newRequest("addImageStore", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AddImageStoreResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type AddImageStoreResponse struct { - Details []string `json:"details,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Protocol string `json:"protocol,omitempty"` - Providername string `json:"providername,omitempty"` - Scope string `json:"scope,omitempty"` - Url string `json:"url,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type AddImageStoreS3Params struct { - p map[string]interface{} -} - -func (p *AddImageStoreS3Params) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["accesskey"]; found { - u.Set("accesskey", v.(string)) - } - if v, found := p.p["bucket"]; found { - u.Set("bucket", v.(string)) - } - if v, found := p.p["connectiontimeout"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("connectiontimeout", vv) - } - if v, found := p.p["connectionttl"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("connectionttl", vv) - } - if v, found := p.p["endpoint"]; found { - u.Set("endpoint", v.(string)) - } - if v, found := p.p["maxerrorretry"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("maxerrorretry", vv) - } - if v, found := p.p["s3signer"]; found { - u.Set("s3signer", v.(string)) - } - if v, found := p.p["secretkey"]; found { - u.Set("secretkey", v.(string)) - } - if v, found := p.p["sockettimeout"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("sockettimeout", vv) - } - if v, found := p.p["usehttps"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("usehttps", vv) - } - if v, found := p.p["usetcpkeepalive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("usetcpkeepalive", vv) - } - return u -} - -func (p *AddImageStoreS3Params) SetAccesskey(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["accesskey"] = v - return -} - -func (p *AddImageStoreS3Params) SetBucket(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["bucket"] = v - return -} - -func (p *AddImageStoreS3Params) SetConnectiontimeout(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["connectiontimeout"] = v - return -} - -func (p *AddImageStoreS3Params) SetConnectionttl(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["connectionttl"] = v - return -} - -func (p *AddImageStoreS3Params) SetEndpoint(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["endpoint"] = v - return -} - -func (p *AddImageStoreS3Params) SetMaxerrorretry(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["maxerrorretry"] = v - return -} - -func (p *AddImageStoreS3Params) SetS3signer(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["s3signer"] = v - return -} - -func (p *AddImageStoreS3Params) SetSecretkey(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["secretkey"] = v - return -} - -func (p *AddImageStoreS3Params) SetSockettimeout(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["sockettimeout"] = v - return -} - -func (p *AddImageStoreS3Params) SetUsehttps(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["usehttps"] = v - return -} - -func (p *AddImageStoreS3Params) SetUsetcpkeepalive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["usetcpkeepalive"] = v - return -} - -// You should always use this function to get a new AddImageStoreS3Params instance, -// as then you are sure you have configured all required params -func (s *ImageStoreService) NewAddImageStoreS3Params(accesskey string, bucket string, endpoint string, secretkey string) *AddImageStoreS3Params { - p := &AddImageStoreS3Params{} - p.p = make(map[string]interface{}) - p.p["accesskey"] = accesskey - p.p["bucket"] = bucket - p.p["endpoint"] = endpoint - p.p["secretkey"] = secretkey - return p -} - -// Adds S3 Image Store -func (s *ImageStoreService) AddImageStoreS3(p *AddImageStoreS3Params) (*AddImageStoreS3Response, error) { - resp, err := s.cs.newRequest("addImageStoreS3", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AddImageStoreS3Response - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type AddImageStoreS3Response struct { - Details []string `json:"details,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Protocol string `json:"protocol,omitempty"` - Providername string `json:"providername,omitempty"` - Scope string `json:"scope,omitempty"` - Url string `json:"url,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type ListImageStoresParams struct { - p map[string]interface{} -} - -func (p *ListImageStoresParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["protocol"]; found { - u.Set("protocol", v.(string)) - } - if v, found := p.p["provider"]; found { - u.Set("provider", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ListImageStoresParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListImageStoresParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListImageStoresParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListImageStoresParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListImageStoresParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListImageStoresParams) SetProtocol(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["protocol"] = v - return -} - -func (p *ListImageStoresParams) SetProvider(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["provider"] = v - return -} - -func (p *ListImageStoresParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ListImageStoresParams instance, -// as then you are sure you have configured all required params -func (s *ImageStoreService) NewListImageStoresParams() *ListImageStoresParams { - p := &ListImageStoresParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *ImageStoreService) GetImageStoreID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListImageStoresParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListImageStores(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.ImageStores[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.ImageStores { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *ImageStoreService) GetImageStoreByName(name string, opts ...OptionFunc) (*ImageStore, int, error) { - id, count, err := s.GetImageStoreID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetImageStoreByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *ImageStoreService) GetImageStoreByID(id string, opts ...OptionFunc) (*ImageStore, int, error) { - p := &ListImageStoresParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListImageStores(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.ImageStores[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for ImageStore UUID: %s!", id) -} - -// Lists image stores. -func (s *ImageStoreService) ListImageStores(p *ListImageStoresParams) (*ListImageStoresResponse, error) { - resp, err := s.cs.newRequest("listImageStores", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListImageStoresResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListImageStoresResponse struct { - Count int `json:"count"` - ImageStores []*ImageStore `json:"imagestore"` -} - -type ImageStore struct { - Details []string `json:"details,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Protocol string `json:"protocol,omitempty"` - Providername string `json:"providername,omitempty"` - Scope string `json:"scope,omitempty"` - Url string `json:"url,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type DeleteImageStoreParams struct { - p map[string]interface{} -} - -func (p *DeleteImageStoreParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteImageStoreParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteImageStoreParams instance, -// as then you are sure you have configured all required params -func (s *ImageStoreService) NewDeleteImageStoreParams(id string) *DeleteImageStoreParams { - p := &DeleteImageStoreParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes an image store or Secondary Storage. -func (s *ImageStoreService) DeleteImageStore(p *DeleteImageStoreParams) (*DeleteImageStoreResponse, error) { - resp, err := s.cs.newRequest("deleteImageStore", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteImageStoreResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type DeleteImageStoreResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} - -type CreateSecondaryStagingStoreParams struct { - p map[string]interface{} -} - -func (p *CreateSecondaryStagingStoreParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["details"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("details[%d].key", i), k) - u.Set(fmt.Sprintf("details[%d].value", i), vv) - i++ - } - } - if v, found := p.p["provider"]; found { - u.Set("provider", v.(string)) - } - if v, found := p.p["scope"]; found { - u.Set("scope", v.(string)) - } - if v, found := p.p["url"]; found { - u.Set("url", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *CreateSecondaryStagingStoreParams) SetDetails(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["details"] = v - return -} - -func (p *CreateSecondaryStagingStoreParams) SetProvider(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["provider"] = v - return -} - -func (p *CreateSecondaryStagingStoreParams) SetScope(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["scope"] = v - return -} - -func (p *CreateSecondaryStagingStoreParams) SetUrl(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["url"] = v - return -} - -func (p *CreateSecondaryStagingStoreParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new CreateSecondaryStagingStoreParams instance, -// as then you are sure you have configured all required params -func (s *ImageStoreService) NewCreateSecondaryStagingStoreParams(url string) *CreateSecondaryStagingStoreParams { - p := &CreateSecondaryStagingStoreParams{} - p.p = make(map[string]interface{}) - p.p["url"] = url - return p -} - -// create secondary staging store. -func (s *ImageStoreService) CreateSecondaryStagingStore(p *CreateSecondaryStagingStoreParams) (*CreateSecondaryStagingStoreResponse, error) { - resp, err := s.cs.newRequest("createSecondaryStagingStore", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateSecondaryStagingStoreResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type CreateSecondaryStagingStoreResponse struct { - Details []string `json:"details,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Protocol string `json:"protocol,omitempty"` - Providername string `json:"providername,omitempty"` - Scope string `json:"scope,omitempty"` - Url string `json:"url,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type ListSecondaryStagingStoresParams struct { - p map[string]interface{} -} - -func (p *ListSecondaryStagingStoresParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["protocol"]; found { - u.Set("protocol", v.(string)) - } - if v, found := p.p["provider"]; found { - u.Set("provider", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ListSecondaryStagingStoresParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListSecondaryStagingStoresParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListSecondaryStagingStoresParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListSecondaryStagingStoresParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListSecondaryStagingStoresParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListSecondaryStagingStoresParams) SetProtocol(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["protocol"] = v - return -} - -func (p *ListSecondaryStagingStoresParams) SetProvider(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["provider"] = v - return -} - -func (p *ListSecondaryStagingStoresParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ListSecondaryStagingStoresParams instance, -// as then you are sure you have configured all required params -func (s *ImageStoreService) NewListSecondaryStagingStoresParams() *ListSecondaryStagingStoresParams { - p := &ListSecondaryStagingStoresParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *ImageStoreService) GetSecondaryStagingStoreID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListSecondaryStagingStoresParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListSecondaryStagingStores(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.SecondaryStagingStores[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.SecondaryStagingStores { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *ImageStoreService) GetSecondaryStagingStoreByName(name string, opts ...OptionFunc) (*SecondaryStagingStore, int, error) { - id, count, err := s.GetSecondaryStagingStoreID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetSecondaryStagingStoreByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *ImageStoreService) GetSecondaryStagingStoreByID(id string, opts ...OptionFunc) (*SecondaryStagingStore, int, error) { - p := &ListSecondaryStagingStoresParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListSecondaryStagingStores(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.SecondaryStagingStores[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for SecondaryStagingStore UUID: %s!", id) -} - -// Lists secondary staging stores. -func (s *ImageStoreService) ListSecondaryStagingStores(p *ListSecondaryStagingStoresParams) (*ListSecondaryStagingStoresResponse, error) { - resp, err := s.cs.newRequest("listSecondaryStagingStores", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListSecondaryStagingStoresResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListSecondaryStagingStoresResponse struct { - Count int `json:"count"` - SecondaryStagingStores []*SecondaryStagingStore `json:"secondarystagingstore"` -} - -type SecondaryStagingStore struct { - Details []string `json:"details,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Protocol string `json:"protocol,omitempty"` - Providername string `json:"providername,omitempty"` - Scope string `json:"scope,omitempty"` - Url string `json:"url,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type DeleteSecondaryStagingStoreParams struct { - p map[string]interface{} -} - -func (p *DeleteSecondaryStagingStoreParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteSecondaryStagingStoreParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteSecondaryStagingStoreParams instance, -// as then you are sure you have configured all required params -func (s *ImageStoreService) NewDeleteSecondaryStagingStoreParams(id string) *DeleteSecondaryStagingStoreParams { - p := &DeleteSecondaryStagingStoreParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a secondary staging store . -func (s *ImageStoreService) DeleteSecondaryStagingStore(p *DeleteSecondaryStagingStoreParams) (*DeleteSecondaryStagingStoreResponse, error) { - resp, err := s.cs.newRequest("deleteSecondaryStagingStore", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteSecondaryStagingStoreResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type DeleteSecondaryStagingStoreResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} - -type UpdateCloudToUseObjectStoreParams struct { - p map[string]interface{} -} - -func (p *UpdateCloudToUseObjectStoreParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["details"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("details[%d].key", i), k) - u.Set(fmt.Sprintf("details[%d].value", i), vv) - i++ - } - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["provider"]; found { - u.Set("provider", v.(string)) - } - if v, found := p.p["url"]; found { - u.Set("url", v.(string)) - } - return u -} - -func (p *UpdateCloudToUseObjectStoreParams) SetDetails(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["details"] = v - return -} - -func (p *UpdateCloudToUseObjectStoreParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *UpdateCloudToUseObjectStoreParams) SetProvider(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["provider"] = v - return -} - -func (p *UpdateCloudToUseObjectStoreParams) SetUrl(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["url"] = v - return -} - -// You should always use this function to get a new UpdateCloudToUseObjectStoreParams instance, -// as then you are sure you have configured all required params -func (s *ImageStoreService) NewUpdateCloudToUseObjectStoreParams(provider string) *UpdateCloudToUseObjectStoreParams { - p := &UpdateCloudToUseObjectStoreParams{} - p.p = make(map[string]interface{}) - p.p["provider"] = provider - return p -} - -// Migrate current NFS secondary storages to use object store. -func (s *ImageStoreService) UpdateCloudToUseObjectStore(p *UpdateCloudToUseObjectStoreParams) (*UpdateCloudToUseObjectStoreResponse, error) { - resp, err := s.cs.newRequest("updateCloudToUseObjectStore", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateCloudToUseObjectStoreResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type UpdateCloudToUseObjectStoreResponse struct { - Details []string `json:"details,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Protocol string `json:"protocol,omitempty"` - Providername string `json:"providername,omitempty"` - Scope string `json:"scope,omitempty"` - Url string `json:"url,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/InternalLBService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/InternalLBService.go deleted file mode 100644 index ba86b3ee387..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/InternalLBService.go +++ /dev/null @@ -1,1004 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type ConfigureInternalLoadBalancerElementParams struct { - p map[string]interface{} -} - -func (p *ConfigureInternalLoadBalancerElementParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["enabled"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("enabled", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *ConfigureInternalLoadBalancerElementParams) SetEnabled(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["enabled"] = v - return -} - -func (p *ConfigureInternalLoadBalancerElementParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new ConfigureInternalLoadBalancerElementParams instance, -// as then you are sure you have configured all required params -func (s *InternalLBService) NewConfigureInternalLoadBalancerElementParams(enabled bool, id string) *ConfigureInternalLoadBalancerElementParams { - p := &ConfigureInternalLoadBalancerElementParams{} - p.p = make(map[string]interface{}) - p.p["enabled"] = enabled - p.p["id"] = id - return p -} - -// Configures an Internal Load Balancer element. -func (s *InternalLBService) ConfigureInternalLoadBalancerElement(p *ConfigureInternalLoadBalancerElementParams) (*ConfigureInternalLoadBalancerElementResponse, error) { - resp, err := s.cs.newRequest("configureInternalLoadBalancerElement", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ConfigureInternalLoadBalancerElementResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type ConfigureInternalLoadBalancerElementResponse struct { - JobID string `json:"jobid,omitempty"` - Enabled bool `json:"enabled,omitempty"` - Id string `json:"id,omitempty"` - Nspid string `json:"nspid,omitempty"` -} - -type CreateInternalLoadBalancerElementParams struct { - p map[string]interface{} -} - -func (p *CreateInternalLoadBalancerElementParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["nspid"]; found { - u.Set("nspid", v.(string)) - } - return u -} - -func (p *CreateInternalLoadBalancerElementParams) SetNspid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["nspid"] = v - return -} - -// You should always use this function to get a new CreateInternalLoadBalancerElementParams instance, -// as then you are sure you have configured all required params -func (s *InternalLBService) NewCreateInternalLoadBalancerElementParams(nspid string) *CreateInternalLoadBalancerElementParams { - p := &CreateInternalLoadBalancerElementParams{} - p.p = make(map[string]interface{}) - p.p["nspid"] = nspid - return p -} - -// Create an Internal Load Balancer element. -func (s *InternalLBService) CreateInternalLoadBalancerElement(p *CreateInternalLoadBalancerElementParams) (*CreateInternalLoadBalancerElementResponse, error) { - resp, err := s.cs.newRequest("createInternalLoadBalancerElement", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateInternalLoadBalancerElementResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateInternalLoadBalancerElementResponse struct { - JobID string `json:"jobid,omitempty"` - Enabled bool `json:"enabled,omitempty"` - Id string `json:"id,omitempty"` - Nspid string `json:"nspid,omitempty"` -} - -type ListInternalLoadBalancerElementsParams struct { - p map[string]interface{} -} - -func (p *ListInternalLoadBalancerElementsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["enabled"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("enabled", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["nspid"]; found { - u.Set("nspid", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - return u -} - -func (p *ListInternalLoadBalancerElementsParams) SetEnabled(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["enabled"] = v - return -} - -func (p *ListInternalLoadBalancerElementsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListInternalLoadBalancerElementsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListInternalLoadBalancerElementsParams) SetNspid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["nspid"] = v - return -} - -func (p *ListInternalLoadBalancerElementsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListInternalLoadBalancerElementsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -// You should always use this function to get a new ListInternalLoadBalancerElementsParams instance, -// as then you are sure you have configured all required params -func (s *InternalLBService) NewListInternalLoadBalancerElementsParams() *ListInternalLoadBalancerElementsParams { - p := &ListInternalLoadBalancerElementsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *InternalLBService) GetInternalLoadBalancerElementByID(id string, opts ...OptionFunc) (*InternalLoadBalancerElement, int, error) { - p := &ListInternalLoadBalancerElementsParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListInternalLoadBalancerElements(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.InternalLoadBalancerElements[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for InternalLoadBalancerElement UUID: %s!", id) -} - -// Lists all available Internal Load Balancer elements. -func (s *InternalLBService) ListInternalLoadBalancerElements(p *ListInternalLoadBalancerElementsParams) (*ListInternalLoadBalancerElementsResponse, error) { - resp, err := s.cs.newRequest("listInternalLoadBalancerElements", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListInternalLoadBalancerElementsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListInternalLoadBalancerElementsResponse struct { - Count int `json:"count"` - InternalLoadBalancerElements []*InternalLoadBalancerElement `json:"internalloadbalancerelement"` -} - -type InternalLoadBalancerElement struct { - Enabled bool `json:"enabled,omitempty"` - Id string `json:"id,omitempty"` - Nspid string `json:"nspid,omitempty"` -} - -type StopInternalLoadBalancerVMParams struct { - p map[string]interface{} -} - -func (p *StopInternalLoadBalancerVMParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["forced"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("forced", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *StopInternalLoadBalancerVMParams) SetForced(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["forced"] = v - return -} - -func (p *StopInternalLoadBalancerVMParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new StopInternalLoadBalancerVMParams instance, -// as then you are sure you have configured all required params -func (s *InternalLBService) NewStopInternalLoadBalancerVMParams(id string) *StopInternalLoadBalancerVMParams { - p := &StopInternalLoadBalancerVMParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Stops an Internal LB vm. -func (s *InternalLBService) StopInternalLoadBalancerVM(p *StopInternalLoadBalancerVMParams) (*StopInternalLoadBalancerVMResponse, error) { - resp, err := s.cs.newRequest("stopInternalLoadBalancerVM", p.toURLValues()) - if err != nil { - return nil, err - } - - var r StopInternalLoadBalancerVMResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type StopInternalLoadBalancerVMResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Created string `json:"created,omitempty"` - Dns1 string `json:"dns1,omitempty"` - Dns2 string `json:"dns2,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Guestipaddress string `json:"guestipaddress,omitempty"` - Guestmacaddress string `json:"guestmacaddress,omitempty"` - Guestnetmask string `json:"guestnetmask,omitempty"` - Guestnetworkid string `json:"guestnetworkid,omitempty"` - Guestnetworkname string `json:"guestnetworkname,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Ip6dns1 string `json:"ip6dns1,omitempty"` - Ip6dns2 string `json:"ip6dns2,omitempty"` - Isredundantrouter bool `json:"isredundantrouter,omitempty"` - Linklocalip string `json:"linklocalip,omitempty"` - Linklocalmacaddress string `json:"linklocalmacaddress,omitempty"` - Linklocalnetmask string `json:"linklocalnetmask,omitempty"` - Linklocalnetworkid string `json:"linklocalnetworkid,omitempty"` - Name string `json:"name,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Podid string `json:"podid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicmacaddress string `json:"publicmacaddress,omitempty"` - Publicnetmask string `json:"publicnetmask,omitempty"` - Publicnetworkid string `json:"publicnetworkid,omitempty"` - Redundantstate string `json:"redundantstate,omitempty"` - Requiresupgrade bool `json:"requiresupgrade,omitempty"` - Role string `json:"role,omitempty"` - Scriptsversion string `json:"scriptsversion,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - State string `json:"state,omitempty"` - Templateid string `json:"templateid,omitempty"` - Version string `json:"version,omitempty"` - Vpcid string `json:"vpcid,omitempty"` - Vpcname string `json:"vpcname,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type StartInternalLoadBalancerVMParams struct { - p map[string]interface{} -} - -func (p *StartInternalLoadBalancerVMParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *StartInternalLoadBalancerVMParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new StartInternalLoadBalancerVMParams instance, -// as then you are sure you have configured all required params -func (s *InternalLBService) NewStartInternalLoadBalancerVMParams(id string) *StartInternalLoadBalancerVMParams { - p := &StartInternalLoadBalancerVMParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Starts an existing internal lb vm. -func (s *InternalLBService) StartInternalLoadBalancerVM(p *StartInternalLoadBalancerVMParams) (*StartInternalLoadBalancerVMResponse, error) { - resp, err := s.cs.newRequest("startInternalLoadBalancerVM", p.toURLValues()) - if err != nil { - return nil, err - } - - var r StartInternalLoadBalancerVMResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type StartInternalLoadBalancerVMResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Created string `json:"created,omitempty"` - Dns1 string `json:"dns1,omitempty"` - Dns2 string `json:"dns2,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Guestipaddress string `json:"guestipaddress,omitempty"` - Guestmacaddress string `json:"guestmacaddress,omitempty"` - Guestnetmask string `json:"guestnetmask,omitempty"` - Guestnetworkid string `json:"guestnetworkid,omitempty"` - Guestnetworkname string `json:"guestnetworkname,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Ip6dns1 string `json:"ip6dns1,omitempty"` - Ip6dns2 string `json:"ip6dns2,omitempty"` - Isredundantrouter bool `json:"isredundantrouter,omitempty"` - Linklocalip string `json:"linklocalip,omitempty"` - Linklocalmacaddress string `json:"linklocalmacaddress,omitempty"` - Linklocalnetmask string `json:"linklocalnetmask,omitempty"` - Linklocalnetworkid string `json:"linklocalnetworkid,omitempty"` - Name string `json:"name,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Podid string `json:"podid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicmacaddress string `json:"publicmacaddress,omitempty"` - Publicnetmask string `json:"publicnetmask,omitempty"` - Publicnetworkid string `json:"publicnetworkid,omitempty"` - Redundantstate string `json:"redundantstate,omitempty"` - Requiresupgrade bool `json:"requiresupgrade,omitempty"` - Role string `json:"role,omitempty"` - Scriptsversion string `json:"scriptsversion,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - State string `json:"state,omitempty"` - Templateid string `json:"templateid,omitempty"` - Version string `json:"version,omitempty"` - Vpcid string `json:"vpcid,omitempty"` - Vpcname string `json:"vpcname,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type ListInternalLoadBalancerVMsParams struct { - p map[string]interface{} -} - -func (p *ListInternalLoadBalancerVMsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["forvpc"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("forvpc", vv) - } - if v, found := p.p["hostid"]; found { - u.Set("hostid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["networkid"]; found { - u.Set("networkid", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["podid"]; found { - u.Set("podid", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["state"]; found { - u.Set("state", v.(string)) - } - if v, found := p.p["vpcid"]; found { - u.Set("vpcid", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ListInternalLoadBalancerVMsParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListInternalLoadBalancerVMsParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListInternalLoadBalancerVMsParams) SetForvpc(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["forvpc"] = v - return -} - -func (p *ListInternalLoadBalancerVMsParams) SetHostid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hostid"] = v - return -} - -func (p *ListInternalLoadBalancerVMsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListInternalLoadBalancerVMsParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListInternalLoadBalancerVMsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListInternalLoadBalancerVMsParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListInternalLoadBalancerVMsParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListInternalLoadBalancerVMsParams) SetNetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkid"] = v - return -} - -func (p *ListInternalLoadBalancerVMsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListInternalLoadBalancerVMsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListInternalLoadBalancerVMsParams) SetPodid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["podid"] = v - return -} - -func (p *ListInternalLoadBalancerVMsParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListInternalLoadBalancerVMsParams) SetState(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["state"] = v - return -} - -func (p *ListInternalLoadBalancerVMsParams) SetVpcid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vpcid"] = v - return -} - -func (p *ListInternalLoadBalancerVMsParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ListInternalLoadBalancerVMsParams instance, -// as then you are sure you have configured all required params -func (s *InternalLBService) NewListInternalLoadBalancerVMsParams() *ListInternalLoadBalancerVMsParams { - p := &ListInternalLoadBalancerVMsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *InternalLBService) GetInternalLoadBalancerVMID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListInternalLoadBalancerVMsParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListInternalLoadBalancerVMs(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.InternalLoadBalancerVMs[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.InternalLoadBalancerVMs { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *InternalLBService) GetInternalLoadBalancerVMByName(name string, opts ...OptionFunc) (*InternalLoadBalancerVM, int, error) { - id, count, err := s.GetInternalLoadBalancerVMID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetInternalLoadBalancerVMByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *InternalLBService) GetInternalLoadBalancerVMByID(id string, opts ...OptionFunc) (*InternalLoadBalancerVM, int, error) { - p := &ListInternalLoadBalancerVMsParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListInternalLoadBalancerVMs(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.InternalLoadBalancerVMs[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for InternalLoadBalancerVM UUID: %s!", id) -} - -// List internal LB VMs. -func (s *InternalLBService) ListInternalLoadBalancerVMs(p *ListInternalLoadBalancerVMsParams) (*ListInternalLoadBalancerVMsResponse, error) { - resp, err := s.cs.newRequest("listInternalLoadBalancerVMs", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListInternalLoadBalancerVMsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListInternalLoadBalancerVMsResponse struct { - Count int `json:"count"` - InternalLoadBalancerVMs []*InternalLoadBalancerVM `json:"internalloadbalancervm"` -} - -type InternalLoadBalancerVM struct { - Account string `json:"account,omitempty"` - Created string `json:"created,omitempty"` - Dns1 string `json:"dns1,omitempty"` - Dns2 string `json:"dns2,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Guestipaddress string `json:"guestipaddress,omitempty"` - Guestmacaddress string `json:"guestmacaddress,omitempty"` - Guestnetmask string `json:"guestnetmask,omitempty"` - Guestnetworkid string `json:"guestnetworkid,omitempty"` - Guestnetworkname string `json:"guestnetworkname,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Ip6dns1 string `json:"ip6dns1,omitempty"` - Ip6dns2 string `json:"ip6dns2,omitempty"` - Isredundantrouter bool `json:"isredundantrouter,omitempty"` - Linklocalip string `json:"linklocalip,omitempty"` - Linklocalmacaddress string `json:"linklocalmacaddress,omitempty"` - Linklocalnetmask string `json:"linklocalnetmask,omitempty"` - Linklocalnetworkid string `json:"linklocalnetworkid,omitempty"` - Name string `json:"name,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Podid string `json:"podid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicmacaddress string `json:"publicmacaddress,omitempty"` - Publicnetmask string `json:"publicnetmask,omitempty"` - Publicnetworkid string `json:"publicnetworkid,omitempty"` - Redundantstate string `json:"redundantstate,omitempty"` - Requiresupgrade bool `json:"requiresupgrade,omitempty"` - Role string `json:"role,omitempty"` - Scriptsversion string `json:"scriptsversion,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - State string `json:"state,omitempty"` - Templateid string `json:"templateid,omitempty"` - Version string `json:"version,omitempty"` - Vpcid string `json:"vpcid,omitempty"` - Vpcname string `json:"vpcname,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/LDAPService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/LDAPService.go deleted file mode 100644 index 18935c294af..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/LDAPService.go +++ /dev/null @@ -1,239 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" -) - -type LdapCreateAccountParams struct { - p map[string]interface{} -} - -func (p *LdapCreateAccountParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["accountdetails"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("accountdetails[%d].key", i), k) - u.Set(fmt.Sprintf("accountdetails[%d].value", i), vv) - i++ - } - } - if v, found := p.p["accountid"]; found { - u.Set("accountid", v.(string)) - } - if v, found := p.p["accounttype"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("accounttype", vv) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["networkdomain"]; found { - u.Set("networkdomain", v.(string)) - } - if v, found := p.p["timezone"]; found { - u.Set("timezone", v.(string)) - } - if v, found := p.p["userid"]; found { - u.Set("userid", v.(string)) - } - if v, found := p.p["username"]; found { - u.Set("username", v.(string)) - } - return u -} - -func (p *LdapCreateAccountParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *LdapCreateAccountParams) SetAccountdetails(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["accountdetails"] = v - return -} - -func (p *LdapCreateAccountParams) SetAccountid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["accountid"] = v - return -} - -func (p *LdapCreateAccountParams) SetAccounttype(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["accounttype"] = v - return -} - -func (p *LdapCreateAccountParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *LdapCreateAccountParams) SetNetworkdomain(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkdomain"] = v - return -} - -func (p *LdapCreateAccountParams) SetTimezone(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["timezone"] = v - return -} - -func (p *LdapCreateAccountParams) SetUserid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["userid"] = v - return -} - -func (p *LdapCreateAccountParams) SetUsername(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["username"] = v - return -} - -// You should always use this function to get a new LdapCreateAccountParams instance, -// as then you are sure you have configured all required params -func (s *LDAPService) NewLdapCreateAccountParams(accounttype int, username string) *LdapCreateAccountParams { - p := &LdapCreateAccountParams{} - p.p = make(map[string]interface{}) - p.p["accounttype"] = accounttype - p.p["username"] = username - return p -} - -// Creates an account from an LDAP user -func (s *LDAPService) LdapCreateAccount(p *LdapCreateAccountParams) (*LdapCreateAccountResponse, error) { - resp, err := s.cs.newRequest("ldapCreateAccount", p.toURLValues()) - if err != nil { - return nil, err - } - - var r LdapCreateAccountResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type LdapCreateAccountResponse struct { - Accountdetails map[string]string `json:"accountdetails,omitempty"` - Accounttype int `json:"accounttype,omitempty"` - Cpuavailable string `json:"cpuavailable,omitempty"` - Cpulimit string `json:"cpulimit,omitempty"` - Cputotal int64 `json:"cputotal,omitempty"` - Defaultzoneid string `json:"defaultzoneid,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Groups []string `json:"groups,omitempty"` - Id string `json:"id,omitempty"` - Ipavailable string `json:"ipavailable,omitempty"` - Iplimit string `json:"iplimit,omitempty"` - Iptotal int64 `json:"iptotal,omitempty"` - Iscleanuprequired bool `json:"iscleanuprequired,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Memoryavailable string `json:"memoryavailable,omitempty"` - Memorylimit string `json:"memorylimit,omitempty"` - Memorytotal int64 `json:"memorytotal,omitempty"` - Name string `json:"name,omitempty"` - Networkavailable string `json:"networkavailable,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Networklimit string `json:"networklimit,omitempty"` - Networktotal int64 `json:"networktotal,omitempty"` - Primarystorageavailable string `json:"primarystorageavailable,omitempty"` - Primarystoragelimit string `json:"primarystoragelimit,omitempty"` - Primarystoragetotal int64 `json:"primarystoragetotal,omitempty"` - Projectavailable string `json:"projectavailable,omitempty"` - Projectlimit string `json:"projectlimit,omitempty"` - Projecttotal int64 `json:"projecttotal,omitempty"` - Receivedbytes int64 `json:"receivedbytes,omitempty"` - Secondarystorageavailable string `json:"secondarystorageavailable,omitempty"` - Secondarystoragelimit string `json:"secondarystoragelimit,omitempty"` - Secondarystoragetotal int64 `json:"secondarystoragetotal,omitempty"` - Sentbytes int64 `json:"sentbytes,omitempty"` - Snapshotavailable string `json:"snapshotavailable,omitempty"` - Snapshotlimit string `json:"snapshotlimit,omitempty"` - Snapshottotal int64 `json:"snapshottotal,omitempty"` - State string `json:"state,omitempty"` - Templateavailable string `json:"templateavailable,omitempty"` - Templatelimit string `json:"templatelimit,omitempty"` - Templatetotal int64 `json:"templatetotal,omitempty"` - User []struct { - Account string `json:"account,omitempty"` - Accountid string `json:"accountid,omitempty"` - Accounttype int `json:"accounttype,omitempty"` - Apikey string `json:"apikey,omitempty"` - Created string `json:"created,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Email string `json:"email,omitempty"` - Firstname string `json:"firstname,omitempty"` - Id string `json:"id,omitempty"` - Iscallerchilddomain bool `json:"iscallerchilddomain,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Lastname string `json:"lastname,omitempty"` - Secretkey string `json:"secretkey,omitempty"` - State string `json:"state,omitempty"` - Timezone string `json:"timezone,omitempty"` - Username string `json:"username,omitempty"` - } `json:"user,omitempty"` - Vmavailable string `json:"vmavailable,omitempty"` - Vmlimit string `json:"vmlimit,omitempty"` - Vmrunning int `json:"vmrunning,omitempty"` - Vmstopped int `json:"vmstopped,omitempty"` - Vmtotal int64 `json:"vmtotal,omitempty"` - Volumeavailable string `json:"volumeavailable,omitempty"` - Volumelimit string `json:"volumelimit,omitempty"` - Volumetotal int64 `json:"volumetotal,omitempty"` - Vpcavailable string `json:"vpcavailable,omitempty"` - Vpclimit string `json:"vpclimit,omitempty"` - Vpctotal int64 `json:"vpctotal,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/LICENSE b/vendor/github.com/xanzy/go-cloudstack/cloudstack/LICENSE deleted file mode 100644 index 5c304d1a4a7..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ -Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/LimitService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/LimitService.go deleted file mode 100644 index 276abecf8a4..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/LimitService.go +++ /dev/null @@ -1,475 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "net/url" - "strconv" -) - -type UpdateResourceLimitParams struct { - p map[string]interface{} -} - -func (p *UpdateResourceLimitParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["max"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("max", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["resourcetype"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("resourcetype", vv) - } - return u -} - -func (p *UpdateResourceLimitParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *UpdateResourceLimitParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *UpdateResourceLimitParams) SetMax(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["max"] = v - return -} - -func (p *UpdateResourceLimitParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *UpdateResourceLimitParams) SetResourcetype(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["resourcetype"] = v - return -} - -// You should always use this function to get a new UpdateResourceLimitParams instance, -// as then you are sure you have configured all required params -func (s *LimitService) NewUpdateResourceLimitParams(resourcetype int) *UpdateResourceLimitParams { - p := &UpdateResourceLimitParams{} - p.p = make(map[string]interface{}) - p.p["resourcetype"] = resourcetype - return p -} - -// Updates resource limits for an account or domain. -func (s *LimitService) UpdateResourceLimit(p *UpdateResourceLimitParams) (*UpdateResourceLimitResponse, error) { - resp, err := s.cs.newRequest("updateResourceLimit", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateResourceLimitResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type UpdateResourceLimitResponse struct { - Account string `json:"account,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Max int64 `json:"max,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` -} - -type UpdateResourceCountParams struct { - p map[string]interface{} -} - -func (p *UpdateResourceCountParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["resourcetype"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("resourcetype", vv) - } - return u -} - -func (p *UpdateResourceCountParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *UpdateResourceCountParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *UpdateResourceCountParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *UpdateResourceCountParams) SetResourcetype(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["resourcetype"] = v - return -} - -// You should always use this function to get a new UpdateResourceCountParams instance, -// as then you are sure you have configured all required params -func (s *LimitService) NewUpdateResourceCountParams(domainid string) *UpdateResourceCountParams { - p := &UpdateResourceCountParams{} - p.p = make(map[string]interface{}) - p.p["domainid"] = domainid - return p -} - -// Recalculate and update resource count for an account or domain. -func (s *LimitService) UpdateResourceCount(p *UpdateResourceCountParams) (*UpdateResourceCountResponse, error) { - resp, err := s.cs.newRequest("updateResourceCount", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateResourceCountResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type UpdateResourceCountResponse struct { - Account string `json:"account,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourcecount int64 `json:"resourcecount,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` -} - -type ListResourceLimitsParams struct { - p map[string]interface{} -} - -func (p *ListResourceLimitsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["id"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("id", vv) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["resourcetype"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("resourcetype", vv) - } - return u -} - -func (p *ListResourceLimitsParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListResourceLimitsParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListResourceLimitsParams) SetId(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListResourceLimitsParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListResourceLimitsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListResourceLimitsParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListResourceLimitsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListResourceLimitsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListResourceLimitsParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListResourceLimitsParams) SetResourcetype(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["resourcetype"] = v - return -} - -// You should always use this function to get a new ListResourceLimitsParams instance, -// as then you are sure you have configured all required params -func (s *LimitService) NewListResourceLimitsParams() *ListResourceLimitsParams { - p := &ListResourceLimitsParams{} - p.p = make(map[string]interface{}) - return p -} - -// Lists resource limits. -func (s *LimitService) ListResourceLimits(p *ListResourceLimitsParams) (*ListResourceLimitsResponse, error) { - resp, err := s.cs.newRequest("listResourceLimits", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListResourceLimitsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListResourceLimitsResponse struct { - Count int `json:"count"` - ResourceLimits []*ResourceLimit `json:"resourcelimit"` -} - -type ResourceLimit struct { - Account string `json:"account,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Max int64 `json:"max,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` -} - -type GetApiLimitParams struct { - p map[string]interface{} -} - -func (p *GetApiLimitParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - return u -} - -// You should always use this function to get a new GetApiLimitParams instance, -// as then you are sure you have configured all required params -func (s *LimitService) NewGetApiLimitParams() *GetApiLimitParams { - p := &GetApiLimitParams{} - p.p = make(map[string]interface{}) - return p -} - -// Get API limit count for the caller -func (s *LimitService) GetApiLimit(p *GetApiLimitParams) (*GetApiLimitResponse, error) { - resp, err := s.cs.newRequest("getApiLimit", p.toURLValues()) - if err != nil { - return nil, err - } - - var r GetApiLimitResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type GetApiLimitResponse struct { - Account string `json:"account,omitempty"` - Accountid string `json:"accountid,omitempty"` - ApiAllowed int `json:"apiAllowed,omitempty"` - ApiIssued int `json:"apiIssued,omitempty"` - ExpireAfter int64 `json:"expireAfter,omitempty"` -} - -type ResetApiLimitParams struct { - p map[string]interface{} -} - -func (p *ResetApiLimitParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - return u -} - -func (p *ResetApiLimitParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -// You should always use this function to get a new ResetApiLimitParams instance, -// as then you are sure you have configured all required params -func (s *LimitService) NewResetApiLimitParams() *ResetApiLimitParams { - p := &ResetApiLimitParams{} - p.p = make(map[string]interface{}) - return p -} - -// Reset api count -func (s *LimitService) ResetApiLimit(p *ResetApiLimitParams) (*ResetApiLimitResponse, error) { - resp, err := s.cs.newRequest("resetApiLimit", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ResetApiLimitResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ResetApiLimitResponse struct { - Account string `json:"account,omitempty"` - Accountid string `json:"accountid,omitempty"` - ApiAllowed int `json:"apiAllowed,omitempty"` - ApiIssued int `json:"apiIssued,omitempty"` - ExpireAfter int64 `json:"expireAfter,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/LoadBalancerService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/LoadBalancerService.go deleted file mode 100644 index 9900a07150e..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/LoadBalancerService.go +++ /dev/null @@ -1,4745 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type CreateLoadBalancerRuleParams struct { - p map[string]interface{} -} - -func (p *CreateLoadBalancerRuleParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["algorithm"]; found { - u.Set("algorithm", v.(string)) - } - if v, found := p.p["cidrlist"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("cidrlist", vv) - } - if v, found := p.p["description"]; found { - u.Set("description", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["networkid"]; found { - u.Set("networkid", v.(string)) - } - if v, found := p.p["openfirewall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("openfirewall", vv) - } - if v, found := p.p["privateport"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("privateport", vv) - } - if v, found := p.p["protocol"]; found { - u.Set("protocol", v.(string)) - } - if v, found := p.p["publicipid"]; found { - u.Set("publicipid", v.(string)) - } - if v, found := p.p["publicport"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("publicport", vv) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *CreateLoadBalancerRuleParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *CreateLoadBalancerRuleParams) SetAlgorithm(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["algorithm"] = v - return -} - -func (p *CreateLoadBalancerRuleParams) SetCidrlist(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["cidrlist"] = v - return -} - -func (p *CreateLoadBalancerRuleParams) SetDescription(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["description"] = v - return -} - -func (p *CreateLoadBalancerRuleParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *CreateLoadBalancerRuleParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *CreateLoadBalancerRuleParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *CreateLoadBalancerRuleParams) SetNetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkid"] = v - return -} - -func (p *CreateLoadBalancerRuleParams) SetOpenfirewall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["openfirewall"] = v - return -} - -func (p *CreateLoadBalancerRuleParams) SetPrivateport(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["privateport"] = v - return -} - -func (p *CreateLoadBalancerRuleParams) SetProtocol(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["protocol"] = v - return -} - -func (p *CreateLoadBalancerRuleParams) SetPublicipid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["publicipid"] = v - return -} - -func (p *CreateLoadBalancerRuleParams) SetPublicport(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["publicport"] = v - return -} - -func (p *CreateLoadBalancerRuleParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new CreateLoadBalancerRuleParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewCreateLoadBalancerRuleParams(algorithm string, name string, privateport int, publicport int) *CreateLoadBalancerRuleParams { - p := &CreateLoadBalancerRuleParams{} - p.p = make(map[string]interface{}) - p.p["algorithm"] = algorithm - p.p["name"] = name - p.p["privateport"] = privateport - p.p["publicport"] = publicport - return p -} - -// Creates a load balancer rule -func (s *LoadBalancerService) CreateLoadBalancerRule(p *CreateLoadBalancerRuleParams) (*CreateLoadBalancerRuleResponse, error) { - resp, err := s.cs.newRequest("createLoadBalancerRule", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateLoadBalancerRuleResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateLoadBalancerRuleResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Algorithm string `json:"algorithm,omitempty"` - Cidrlist string `json:"cidrlist,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Networkid string `json:"networkid,omitempty"` - Privateport string `json:"privateport,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Protocol string `json:"protocol,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - Publicport string `json:"publicport,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type DeleteLoadBalancerRuleParams struct { - p map[string]interface{} -} - -func (p *DeleteLoadBalancerRuleParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteLoadBalancerRuleParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteLoadBalancerRuleParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewDeleteLoadBalancerRuleParams(id string) *DeleteLoadBalancerRuleParams { - p := &DeleteLoadBalancerRuleParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a load balancer rule. -func (s *LoadBalancerService) DeleteLoadBalancerRule(p *DeleteLoadBalancerRuleParams) (*DeleteLoadBalancerRuleResponse, error) { - resp, err := s.cs.newRequest("deleteLoadBalancerRule", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteLoadBalancerRuleResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteLoadBalancerRuleResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type RemoveFromLoadBalancerRuleParams struct { - p map[string]interface{} -} - -func (p *RemoveFromLoadBalancerRuleParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["virtualmachineids"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("virtualmachineids", vv) - } - if v, found := p.p["vmidipmap"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("vmidipmap[%d].key", i), k) - u.Set(fmt.Sprintf("vmidipmap[%d].value", i), vv) - i++ - } - } - return u -} - -func (p *RemoveFromLoadBalancerRuleParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *RemoveFromLoadBalancerRuleParams) SetVirtualmachineids(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["virtualmachineids"] = v - return -} - -func (p *RemoveFromLoadBalancerRuleParams) SetVmidipmap(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vmidipmap"] = v - return -} - -// You should always use this function to get a new RemoveFromLoadBalancerRuleParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewRemoveFromLoadBalancerRuleParams(id string) *RemoveFromLoadBalancerRuleParams { - p := &RemoveFromLoadBalancerRuleParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Removes a virtual machine or a list of virtual machines from a load balancer rule. -func (s *LoadBalancerService) RemoveFromLoadBalancerRule(p *RemoveFromLoadBalancerRuleParams) (*RemoveFromLoadBalancerRuleResponse, error) { - resp, err := s.cs.newRequest("removeFromLoadBalancerRule", p.toURLValues()) - if err != nil { - return nil, err - } - - var r RemoveFromLoadBalancerRuleResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type RemoveFromLoadBalancerRuleResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type AssignToLoadBalancerRuleParams struct { - p map[string]interface{} -} - -func (p *AssignToLoadBalancerRuleParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["virtualmachineids"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("virtualmachineids", vv) - } - if v, found := p.p["vmidipmap"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("vmidipmap[%d].key", i), k) - u.Set(fmt.Sprintf("vmidipmap[%d].value", i), vv) - i++ - } - } - return u -} - -func (p *AssignToLoadBalancerRuleParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *AssignToLoadBalancerRuleParams) SetVirtualmachineids(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["virtualmachineids"] = v - return -} - -func (p *AssignToLoadBalancerRuleParams) SetVmidipmap(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vmidipmap"] = v - return -} - -// You should always use this function to get a new AssignToLoadBalancerRuleParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewAssignToLoadBalancerRuleParams(id string) *AssignToLoadBalancerRuleParams { - p := &AssignToLoadBalancerRuleParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Assigns virtual machine or a list of virtual machines to a load balancer rule. -func (s *LoadBalancerService) AssignToLoadBalancerRule(p *AssignToLoadBalancerRuleParams) (*AssignToLoadBalancerRuleResponse, error) { - resp, err := s.cs.newRequest("assignToLoadBalancerRule", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AssignToLoadBalancerRuleResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type AssignToLoadBalancerRuleResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type CreateLBStickinessPolicyParams struct { - p map[string]interface{} -} - -func (p *CreateLBStickinessPolicyParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["description"]; found { - u.Set("description", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["lbruleid"]; found { - u.Set("lbruleid", v.(string)) - } - if v, found := p.p["methodname"]; found { - u.Set("methodname", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["param"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("param[%d].key", i), k) - u.Set(fmt.Sprintf("param[%d].value", i), vv) - i++ - } - } - return u -} - -func (p *CreateLBStickinessPolicyParams) SetDescription(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["description"] = v - return -} - -func (p *CreateLBStickinessPolicyParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *CreateLBStickinessPolicyParams) SetLbruleid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["lbruleid"] = v - return -} - -func (p *CreateLBStickinessPolicyParams) SetMethodname(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["methodname"] = v - return -} - -func (p *CreateLBStickinessPolicyParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *CreateLBStickinessPolicyParams) SetParam(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["param"] = v - return -} - -// You should always use this function to get a new CreateLBStickinessPolicyParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewCreateLBStickinessPolicyParams(lbruleid string, methodname string, name string) *CreateLBStickinessPolicyParams { - p := &CreateLBStickinessPolicyParams{} - p.p = make(map[string]interface{}) - p.p["lbruleid"] = lbruleid - p.p["methodname"] = methodname - p.p["name"] = name - return p -} - -// Creates a load balancer stickiness policy -func (s *LoadBalancerService) CreateLBStickinessPolicy(p *CreateLBStickinessPolicyParams) (*CreateLBStickinessPolicyResponse, error) { - resp, err := s.cs.newRequest("createLBStickinessPolicy", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateLBStickinessPolicyResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateLBStickinessPolicyResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Lbruleid string `json:"lbruleid,omitempty"` - Name string `json:"name,omitempty"` - State string `json:"state,omitempty"` - Stickinesspolicy []struct { - Description string `json:"description,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Methodname string `json:"methodname,omitempty"` - Name string `json:"name,omitempty"` - Params map[string]string `json:"params,omitempty"` - State string `json:"state,omitempty"` - } `json:"stickinesspolicy,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type UpdateLBStickinessPolicyParams struct { - p map[string]interface{} -} - -func (p *UpdateLBStickinessPolicyParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["customid"]; found { - u.Set("customid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *UpdateLBStickinessPolicyParams) SetCustomid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["customid"] = v - return -} - -func (p *UpdateLBStickinessPolicyParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *UpdateLBStickinessPolicyParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new UpdateLBStickinessPolicyParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewUpdateLBStickinessPolicyParams(id string) *UpdateLBStickinessPolicyParams { - p := &UpdateLBStickinessPolicyParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates load balancer stickiness policy -func (s *LoadBalancerService) UpdateLBStickinessPolicy(p *UpdateLBStickinessPolicyParams) (*UpdateLBStickinessPolicyResponse, error) { - resp, err := s.cs.newRequest("updateLBStickinessPolicy", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateLBStickinessPolicyResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateLBStickinessPolicyResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Lbruleid string `json:"lbruleid,omitempty"` - Name string `json:"name,omitempty"` - State string `json:"state,omitempty"` - Stickinesspolicy []struct { - Description string `json:"description,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Methodname string `json:"methodname,omitempty"` - Name string `json:"name,omitempty"` - Params map[string]string `json:"params,omitempty"` - State string `json:"state,omitempty"` - } `json:"stickinesspolicy,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type DeleteLBStickinessPolicyParams struct { - p map[string]interface{} -} - -func (p *DeleteLBStickinessPolicyParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteLBStickinessPolicyParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteLBStickinessPolicyParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewDeleteLBStickinessPolicyParams(id string) *DeleteLBStickinessPolicyParams { - p := &DeleteLBStickinessPolicyParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a load balancer stickiness policy. -func (s *LoadBalancerService) DeleteLBStickinessPolicy(p *DeleteLBStickinessPolicyParams) (*DeleteLBStickinessPolicyResponse, error) { - resp, err := s.cs.newRequest("deleteLBStickinessPolicy", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteLBStickinessPolicyResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteLBStickinessPolicyResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListLoadBalancerRulesParams struct { - p map[string]interface{} -} - -func (p *ListLoadBalancerRulesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["networkid"]; found { - u.Set("networkid", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["publicipid"]; found { - u.Set("publicipid", v.(string)) - } - if v, found := p.p["tags"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("tags[%d].key", i), k) - u.Set(fmt.Sprintf("tags[%d].value", i), vv) - i++ - } - } - if v, found := p.p["virtualmachineid"]; found { - u.Set("virtualmachineid", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ListLoadBalancerRulesParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListLoadBalancerRulesParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListLoadBalancerRulesParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *ListLoadBalancerRulesParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListLoadBalancerRulesParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListLoadBalancerRulesParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListLoadBalancerRulesParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListLoadBalancerRulesParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListLoadBalancerRulesParams) SetNetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkid"] = v - return -} - -func (p *ListLoadBalancerRulesParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListLoadBalancerRulesParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListLoadBalancerRulesParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListLoadBalancerRulesParams) SetPublicipid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["publicipid"] = v - return -} - -func (p *ListLoadBalancerRulesParams) SetTags(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tags"] = v - return -} - -func (p *ListLoadBalancerRulesParams) SetVirtualmachineid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["virtualmachineid"] = v - return -} - -func (p *ListLoadBalancerRulesParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ListLoadBalancerRulesParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewListLoadBalancerRulesParams() *ListLoadBalancerRulesParams { - p := &ListLoadBalancerRulesParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *LoadBalancerService) GetLoadBalancerRuleID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListLoadBalancerRulesParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListLoadBalancerRules(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.LoadBalancerRules[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.LoadBalancerRules { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *LoadBalancerService) GetLoadBalancerRuleByName(name string, opts ...OptionFunc) (*LoadBalancerRule, int, error) { - id, count, err := s.GetLoadBalancerRuleID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetLoadBalancerRuleByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *LoadBalancerService) GetLoadBalancerRuleByID(id string, opts ...OptionFunc) (*LoadBalancerRule, int, error) { - p := &ListLoadBalancerRulesParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListLoadBalancerRules(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.LoadBalancerRules[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for LoadBalancerRule UUID: %s!", id) -} - -// Lists load balancer rules. -func (s *LoadBalancerService) ListLoadBalancerRules(p *ListLoadBalancerRulesParams) (*ListLoadBalancerRulesResponse, error) { - resp, err := s.cs.newRequest("listLoadBalancerRules", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListLoadBalancerRulesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListLoadBalancerRulesResponse struct { - Count int `json:"count"` - LoadBalancerRules []*LoadBalancerRule `json:"loadbalancerrule"` -} - -type LoadBalancerRule struct { - Account string `json:"account,omitempty"` - Algorithm string `json:"algorithm,omitempty"` - Cidrlist string `json:"cidrlist,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Networkid string `json:"networkid,omitempty"` - Privateport string `json:"privateport,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Protocol string `json:"protocol,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - Publicport string `json:"publicport,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type ListLBStickinessPoliciesParams struct { - p map[string]interface{} -} - -func (p *ListLBStickinessPoliciesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["lbruleid"]; found { - u.Set("lbruleid", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - return u -} - -func (p *ListLBStickinessPoliciesParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *ListLBStickinessPoliciesParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListLBStickinessPoliciesParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListLBStickinessPoliciesParams) SetLbruleid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["lbruleid"] = v - return -} - -func (p *ListLBStickinessPoliciesParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListLBStickinessPoliciesParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -// You should always use this function to get a new ListLBStickinessPoliciesParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewListLBStickinessPoliciesParams() *ListLBStickinessPoliciesParams { - p := &ListLBStickinessPoliciesParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *LoadBalancerService) GetLBStickinessPolicyByID(id string, opts ...OptionFunc) (*LBStickinessPolicy, int, error) { - p := &ListLBStickinessPoliciesParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListLBStickinessPolicies(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.LBStickinessPolicies[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for LBStickinessPolicy UUID: %s!", id) -} - -// Lists load balancer stickiness policies. -func (s *LoadBalancerService) ListLBStickinessPolicies(p *ListLBStickinessPoliciesParams) (*ListLBStickinessPoliciesResponse, error) { - resp, err := s.cs.newRequest("listLBStickinessPolicies", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListLBStickinessPoliciesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListLBStickinessPoliciesResponse struct { - Count int `json:"count"` - LBStickinessPolicies []*LBStickinessPolicy `json:"lbstickinesspolicy"` -} - -type LBStickinessPolicy struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Lbruleid string `json:"lbruleid,omitempty"` - Name string `json:"name,omitempty"` - State string `json:"state,omitempty"` - Stickinesspolicy []struct { - Description string `json:"description,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Methodname string `json:"methodname,omitempty"` - Name string `json:"name,omitempty"` - Params map[string]string `json:"params,omitempty"` - State string `json:"state,omitempty"` - } `json:"stickinesspolicy,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type ListLBHealthCheckPoliciesParams struct { - p map[string]interface{} -} - -func (p *ListLBHealthCheckPoliciesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["lbruleid"]; found { - u.Set("lbruleid", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - return u -} - -func (p *ListLBHealthCheckPoliciesParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *ListLBHealthCheckPoliciesParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListLBHealthCheckPoliciesParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListLBHealthCheckPoliciesParams) SetLbruleid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["lbruleid"] = v - return -} - -func (p *ListLBHealthCheckPoliciesParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListLBHealthCheckPoliciesParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -// You should always use this function to get a new ListLBHealthCheckPoliciesParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewListLBHealthCheckPoliciesParams() *ListLBHealthCheckPoliciesParams { - p := &ListLBHealthCheckPoliciesParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *LoadBalancerService) GetLBHealthCheckPolicyByID(id string, opts ...OptionFunc) (*LBHealthCheckPolicy, int, error) { - p := &ListLBHealthCheckPoliciesParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListLBHealthCheckPolicies(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.LBHealthCheckPolicies[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for LBHealthCheckPolicy UUID: %s!", id) -} - -// Lists load balancer health check policies. -func (s *LoadBalancerService) ListLBHealthCheckPolicies(p *ListLBHealthCheckPoliciesParams) (*ListLBHealthCheckPoliciesResponse, error) { - resp, err := s.cs.newRequest("listLBHealthCheckPolicies", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListLBHealthCheckPoliciesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListLBHealthCheckPoliciesResponse struct { - Count int `json:"count"` - LBHealthCheckPolicies []*LBHealthCheckPolicy `json:"lbhealthcheckpolicy"` -} - -type LBHealthCheckPolicy struct { - Account string `json:"account,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Healthcheckpolicy []struct { - Description string `json:"description,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Healthcheckinterval int `json:"healthcheckinterval,omitempty"` - Healthcheckthresshold int `json:"healthcheckthresshold,omitempty"` - Id string `json:"id,omitempty"` - Pingpath string `json:"pingpath,omitempty"` - Responsetime int `json:"responsetime,omitempty"` - State string `json:"state,omitempty"` - Unhealthcheckthresshold int `json:"unhealthcheckthresshold,omitempty"` - } `json:"healthcheckpolicy,omitempty"` - Lbruleid string `json:"lbruleid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type CreateLBHealthCheckPolicyParams struct { - p map[string]interface{} -} - -func (p *CreateLBHealthCheckPolicyParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["description"]; found { - u.Set("description", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["healthythreshold"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("healthythreshold", vv) - } - if v, found := p.p["intervaltime"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("intervaltime", vv) - } - if v, found := p.p["lbruleid"]; found { - u.Set("lbruleid", v.(string)) - } - if v, found := p.p["pingpath"]; found { - u.Set("pingpath", v.(string)) - } - if v, found := p.p["responsetimeout"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("responsetimeout", vv) - } - if v, found := p.p["unhealthythreshold"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("unhealthythreshold", vv) - } - return u -} - -func (p *CreateLBHealthCheckPolicyParams) SetDescription(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["description"] = v - return -} - -func (p *CreateLBHealthCheckPolicyParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *CreateLBHealthCheckPolicyParams) SetHealthythreshold(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["healthythreshold"] = v - return -} - -func (p *CreateLBHealthCheckPolicyParams) SetIntervaltime(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["intervaltime"] = v - return -} - -func (p *CreateLBHealthCheckPolicyParams) SetLbruleid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["lbruleid"] = v - return -} - -func (p *CreateLBHealthCheckPolicyParams) SetPingpath(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pingpath"] = v - return -} - -func (p *CreateLBHealthCheckPolicyParams) SetResponsetimeout(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["responsetimeout"] = v - return -} - -func (p *CreateLBHealthCheckPolicyParams) SetUnhealthythreshold(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["unhealthythreshold"] = v - return -} - -// You should always use this function to get a new CreateLBHealthCheckPolicyParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewCreateLBHealthCheckPolicyParams(lbruleid string) *CreateLBHealthCheckPolicyParams { - p := &CreateLBHealthCheckPolicyParams{} - p.p = make(map[string]interface{}) - p.p["lbruleid"] = lbruleid - return p -} - -// Creates a load balancer health check policy -func (s *LoadBalancerService) CreateLBHealthCheckPolicy(p *CreateLBHealthCheckPolicyParams) (*CreateLBHealthCheckPolicyResponse, error) { - resp, err := s.cs.newRequest("createLBHealthCheckPolicy", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateLBHealthCheckPolicyResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateLBHealthCheckPolicyResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Healthcheckpolicy []struct { - Description string `json:"description,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Healthcheckinterval int `json:"healthcheckinterval,omitempty"` - Healthcheckthresshold int `json:"healthcheckthresshold,omitempty"` - Id string `json:"id,omitempty"` - Pingpath string `json:"pingpath,omitempty"` - Responsetime int `json:"responsetime,omitempty"` - State string `json:"state,omitempty"` - Unhealthcheckthresshold int `json:"unhealthcheckthresshold,omitempty"` - } `json:"healthcheckpolicy,omitempty"` - Lbruleid string `json:"lbruleid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type UpdateLBHealthCheckPolicyParams struct { - p map[string]interface{} -} - -func (p *UpdateLBHealthCheckPolicyParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["customid"]; found { - u.Set("customid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *UpdateLBHealthCheckPolicyParams) SetCustomid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["customid"] = v - return -} - -func (p *UpdateLBHealthCheckPolicyParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *UpdateLBHealthCheckPolicyParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new UpdateLBHealthCheckPolicyParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewUpdateLBHealthCheckPolicyParams(id string) *UpdateLBHealthCheckPolicyParams { - p := &UpdateLBHealthCheckPolicyParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates load balancer health check policy -func (s *LoadBalancerService) UpdateLBHealthCheckPolicy(p *UpdateLBHealthCheckPolicyParams) (*UpdateLBHealthCheckPolicyResponse, error) { - resp, err := s.cs.newRequest("updateLBHealthCheckPolicy", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateLBHealthCheckPolicyResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateLBHealthCheckPolicyResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Healthcheckpolicy []struct { - Description string `json:"description,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Healthcheckinterval int `json:"healthcheckinterval,omitempty"` - Healthcheckthresshold int `json:"healthcheckthresshold,omitempty"` - Id string `json:"id,omitempty"` - Pingpath string `json:"pingpath,omitempty"` - Responsetime int `json:"responsetime,omitempty"` - State string `json:"state,omitempty"` - Unhealthcheckthresshold int `json:"unhealthcheckthresshold,omitempty"` - } `json:"healthcheckpolicy,omitempty"` - Lbruleid string `json:"lbruleid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type DeleteLBHealthCheckPolicyParams struct { - p map[string]interface{} -} - -func (p *DeleteLBHealthCheckPolicyParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteLBHealthCheckPolicyParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteLBHealthCheckPolicyParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewDeleteLBHealthCheckPolicyParams(id string) *DeleteLBHealthCheckPolicyParams { - p := &DeleteLBHealthCheckPolicyParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a load balancer health check policy. -func (s *LoadBalancerService) DeleteLBHealthCheckPolicy(p *DeleteLBHealthCheckPolicyParams) (*DeleteLBHealthCheckPolicyResponse, error) { - resp, err := s.cs.newRequest("deleteLBHealthCheckPolicy", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteLBHealthCheckPolicyResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteLBHealthCheckPolicyResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListLoadBalancerRuleInstancesParams struct { - p map[string]interface{} -} - -func (p *ListLoadBalancerRuleInstancesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["applied"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("applied", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["lbvmips"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("lbvmips", vv) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - return u -} - -func (p *ListLoadBalancerRuleInstancesParams) SetApplied(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["applied"] = v - return -} - -func (p *ListLoadBalancerRuleInstancesParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListLoadBalancerRuleInstancesParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListLoadBalancerRuleInstancesParams) SetLbvmips(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["lbvmips"] = v - return -} - -func (p *ListLoadBalancerRuleInstancesParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListLoadBalancerRuleInstancesParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -// You should always use this function to get a new ListLoadBalancerRuleInstancesParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewListLoadBalancerRuleInstancesParams(id string) *ListLoadBalancerRuleInstancesParams { - p := &ListLoadBalancerRuleInstancesParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *LoadBalancerService) GetLoadBalancerRuleInstanceByID(id string, opts ...OptionFunc) (*VirtualMachine, int, error) { - p := &ListLoadBalancerRuleInstancesParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListLoadBalancerRuleInstances(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.LoadBalancerRuleInstances[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for LoadBalancerRuleInstance UUID: %s!", id) -} - -// List all virtual machine instances that are assigned to a load balancer rule. -func (s *LoadBalancerService) ListLoadBalancerRuleInstances(p *ListLoadBalancerRuleInstancesParams) (*ListLoadBalancerRuleInstancesResponse, error) { - resp, err := s.cs.newRequest("listLoadBalancerRuleInstances", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListLoadBalancerRuleInstancesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListLoadBalancerRuleInstancesResponse struct { - Count int `json:"count"` - LBRuleVMIDIPs []*LoadBalancerRuleInstance `json:"lbrulevmidip,omitempty"` - LoadBalancerRuleInstances []*VirtualMachine `json:"loadbalancerruleinstance,omitempty"` -} - -type LoadBalancerRuleInstance struct { - Lbvmipaddresses []string `json:"lbvmipaddresses,omitempty"` - Loadbalancerruleinstance *VirtualMachine `json:"loadbalancerruleinstance,omitempty"` -} - -type UpdateLoadBalancerRuleParams struct { - p map[string]interface{} -} - -func (p *UpdateLoadBalancerRuleParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["algorithm"]; found { - u.Set("algorithm", v.(string)) - } - if v, found := p.p["customid"]; found { - u.Set("customid", v.(string)) - } - if v, found := p.p["description"]; found { - u.Set("description", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - return u -} - -func (p *UpdateLoadBalancerRuleParams) SetAlgorithm(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["algorithm"] = v - return -} - -func (p *UpdateLoadBalancerRuleParams) SetCustomid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["customid"] = v - return -} - -func (p *UpdateLoadBalancerRuleParams) SetDescription(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["description"] = v - return -} - -func (p *UpdateLoadBalancerRuleParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *UpdateLoadBalancerRuleParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateLoadBalancerRuleParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -// You should always use this function to get a new UpdateLoadBalancerRuleParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewUpdateLoadBalancerRuleParams(id string) *UpdateLoadBalancerRuleParams { - p := &UpdateLoadBalancerRuleParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates load balancer -func (s *LoadBalancerService) UpdateLoadBalancerRule(p *UpdateLoadBalancerRuleParams) (*UpdateLoadBalancerRuleResponse, error) { - resp, err := s.cs.newRequest("updateLoadBalancerRule", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateLoadBalancerRuleResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateLoadBalancerRuleResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Algorithm string `json:"algorithm,omitempty"` - Cidrlist string `json:"cidrlist,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Networkid string `json:"networkid,omitempty"` - Privateport string `json:"privateport,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Protocol string `json:"protocol,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - Publicport string `json:"publicport,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type UploadSslCertParams struct { - p map[string]interface{} -} - -func (p *UploadSslCertParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["certchain"]; found { - u.Set("certchain", v.(string)) - } - if v, found := p.p["certificate"]; found { - u.Set("certificate", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["password"]; found { - u.Set("password", v.(string)) - } - if v, found := p.p["privatekey"]; found { - u.Set("privatekey", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - return u -} - -func (p *UploadSslCertParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *UploadSslCertParams) SetCertchain(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["certchain"] = v - return -} - -func (p *UploadSslCertParams) SetCertificate(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["certificate"] = v - return -} - -func (p *UploadSslCertParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *UploadSslCertParams) SetPassword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["password"] = v - return -} - -func (p *UploadSslCertParams) SetPrivatekey(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["privatekey"] = v - return -} - -func (p *UploadSslCertParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -// You should always use this function to get a new UploadSslCertParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewUploadSslCertParams(certificate string, privatekey string) *UploadSslCertParams { - p := &UploadSslCertParams{} - p.p = make(map[string]interface{}) - p.p["certificate"] = certificate - p.p["privatekey"] = privatekey - return p -} - -// Upload a certificate to CloudStack -func (s *LoadBalancerService) UploadSslCert(p *UploadSslCertParams) (*UploadSslCertResponse, error) { - resp, err := s.cs.newRequest("uploadSslCert", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UploadSslCertResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type UploadSslCertResponse struct { - Account string `json:"account,omitempty"` - Certchain string `json:"certchain,omitempty"` - Certificate string `json:"certificate,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fingerprint string `json:"fingerprint,omitempty"` - Id string `json:"id,omitempty"` - Loadbalancerrulelist []string `json:"loadbalancerrulelist,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` -} - -type DeleteSslCertParams struct { - p map[string]interface{} -} - -func (p *DeleteSslCertParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteSslCertParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteSslCertParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewDeleteSslCertParams(id string) *DeleteSslCertParams { - p := &DeleteSslCertParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Delete a certificate to CloudStack -func (s *LoadBalancerService) DeleteSslCert(p *DeleteSslCertParams) (*DeleteSslCertResponse, error) { - resp, err := s.cs.newRequest("deleteSslCert", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteSslCertResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type DeleteSslCertResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} - -type ListSslCertsParams struct { - p map[string]interface{} -} - -func (p *ListSslCertsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["accountid"]; found { - u.Set("accountid", v.(string)) - } - if v, found := p.p["certid"]; found { - u.Set("certid", v.(string)) - } - if v, found := p.p["lbruleid"]; found { - u.Set("lbruleid", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - return u -} - -func (p *ListSslCertsParams) SetAccountid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["accountid"] = v - return -} - -func (p *ListSslCertsParams) SetCertid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["certid"] = v - return -} - -func (p *ListSslCertsParams) SetLbruleid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["lbruleid"] = v - return -} - -func (p *ListSslCertsParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -// You should always use this function to get a new ListSslCertsParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewListSslCertsParams() *ListSslCertsParams { - p := &ListSslCertsParams{} - p.p = make(map[string]interface{}) - return p -} - -// Lists SSL certificates -func (s *LoadBalancerService) ListSslCerts(p *ListSslCertsParams) (*ListSslCertsResponse, error) { - resp, err := s.cs.newRequest("listSslCerts", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListSslCertsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListSslCertsResponse struct { - Count int `json:"count"` - SslCerts []*SslCert `json:"sslcert"` -} - -type SslCert struct { - Account string `json:"account,omitempty"` - Certchain string `json:"certchain,omitempty"` - Certificate string `json:"certificate,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fingerprint string `json:"fingerprint,omitempty"` - Id string `json:"id,omitempty"` - Loadbalancerrulelist []string `json:"loadbalancerrulelist,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` -} - -type AssignCertToLoadBalancerParams struct { - p map[string]interface{} -} - -func (p *AssignCertToLoadBalancerParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["certid"]; found { - u.Set("certid", v.(string)) - } - if v, found := p.p["lbruleid"]; found { - u.Set("lbruleid", v.(string)) - } - return u -} - -func (p *AssignCertToLoadBalancerParams) SetCertid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["certid"] = v - return -} - -func (p *AssignCertToLoadBalancerParams) SetLbruleid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["lbruleid"] = v - return -} - -// You should always use this function to get a new AssignCertToLoadBalancerParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewAssignCertToLoadBalancerParams(certid string, lbruleid string) *AssignCertToLoadBalancerParams { - p := &AssignCertToLoadBalancerParams{} - p.p = make(map[string]interface{}) - p.p["certid"] = certid - p.p["lbruleid"] = lbruleid - return p -} - -// Assigns a certificate to a load balancer rule -func (s *LoadBalancerService) AssignCertToLoadBalancer(p *AssignCertToLoadBalancerParams) (*AssignCertToLoadBalancerResponse, error) { - resp, err := s.cs.newRequest("assignCertToLoadBalancer", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AssignCertToLoadBalancerResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type AssignCertToLoadBalancerResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type RemoveCertFromLoadBalancerParams struct { - p map[string]interface{} -} - -func (p *RemoveCertFromLoadBalancerParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["lbruleid"]; found { - u.Set("lbruleid", v.(string)) - } - return u -} - -func (p *RemoveCertFromLoadBalancerParams) SetLbruleid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["lbruleid"] = v - return -} - -// You should always use this function to get a new RemoveCertFromLoadBalancerParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewRemoveCertFromLoadBalancerParams(lbruleid string) *RemoveCertFromLoadBalancerParams { - p := &RemoveCertFromLoadBalancerParams{} - p.p = make(map[string]interface{}) - p.p["lbruleid"] = lbruleid - return p -} - -// Removes a certificate from a load balancer rule -func (s *LoadBalancerService) RemoveCertFromLoadBalancer(p *RemoveCertFromLoadBalancerParams) (*RemoveCertFromLoadBalancerResponse, error) { - resp, err := s.cs.newRequest("removeCertFromLoadBalancer", p.toURLValues()) - if err != nil { - return nil, err - } - - var r RemoveCertFromLoadBalancerResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type RemoveCertFromLoadBalancerResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type AddNetscalerLoadBalancerParams struct { - p map[string]interface{} -} - -func (p *AddNetscalerLoadBalancerParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["gslbprovider"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("gslbprovider", vv) - } - if v, found := p.p["gslbproviderprivateip"]; found { - u.Set("gslbproviderprivateip", v.(string)) - } - if v, found := p.p["gslbproviderpublicip"]; found { - u.Set("gslbproviderpublicip", v.(string)) - } - if v, found := p.p["isexclusivegslbprovider"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isexclusivegslbprovider", vv) - } - if v, found := p.p["networkdevicetype"]; found { - u.Set("networkdevicetype", v.(string)) - } - if v, found := p.p["password"]; found { - u.Set("password", v.(string)) - } - if v, found := p.p["physicalnetworkid"]; found { - u.Set("physicalnetworkid", v.(string)) - } - if v, found := p.p["url"]; found { - u.Set("url", v.(string)) - } - if v, found := p.p["username"]; found { - u.Set("username", v.(string)) - } - return u -} - -func (p *AddNetscalerLoadBalancerParams) SetGslbprovider(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["gslbprovider"] = v - return -} - -func (p *AddNetscalerLoadBalancerParams) SetGslbproviderprivateip(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["gslbproviderprivateip"] = v - return -} - -func (p *AddNetscalerLoadBalancerParams) SetGslbproviderpublicip(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["gslbproviderpublicip"] = v - return -} - -func (p *AddNetscalerLoadBalancerParams) SetIsexclusivegslbprovider(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isexclusivegslbprovider"] = v - return -} - -func (p *AddNetscalerLoadBalancerParams) SetNetworkdevicetype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkdevicetype"] = v - return -} - -func (p *AddNetscalerLoadBalancerParams) SetPassword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["password"] = v - return -} - -func (p *AddNetscalerLoadBalancerParams) SetPhysicalnetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["physicalnetworkid"] = v - return -} - -func (p *AddNetscalerLoadBalancerParams) SetUrl(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["url"] = v - return -} - -func (p *AddNetscalerLoadBalancerParams) SetUsername(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["username"] = v - return -} - -// You should always use this function to get a new AddNetscalerLoadBalancerParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewAddNetscalerLoadBalancerParams(networkdevicetype string, password string, physicalnetworkid string, url string, username string) *AddNetscalerLoadBalancerParams { - p := &AddNetscalerLoadBalancerParams{} - p.p = make(map[string]interface{}) - p.p["networkdevicetype"] = networkdevicetype - p.p["password"] = password - p.p["physicalnetworkid"] = physicalnetworkid - p.p["url"] = url - p.p["username"] = username - return p -} - -// Adds a netscaler load balancer device -func (s *LoadBalancerService) AddNetscalerLoadBalancer(p *AddNetscalerLoadBalancerParams) (*AddNetscalerLoadBalancerResponse, error) { - resp, err := s.cs.newRequest("addNetscalerLoadBalancer", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AddNetscalerLoadBalancerResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type AddNetscalerLoadBalancerResponse struct { - JobID string `json:"jobid,omitempty"` - Gslbprovider bool `json:"gslbprovider,omitempty"` - Gslbproviderprivateip string `json:"gslbproviderprivateip,omitempty"` - Gslbproviderpublicip string `json:"gslbproviderpublicip,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isexclusivegslbprovider bool `json:"isexclusivegslbprovider,omitempty"` - Lbdevicecapacity int64 `json:"lbdevicecapacity,omitempty"` - Lbdevicededicated bool `json:"lbdevicededicated,omitempty"` - Lbdeviceid string `json:"lbdeviceid,omitempty"` - Lbdevicename string `json:"lbdevicename,omitempty"` - Lbdevicestate string `json:"lbdevicestate,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Podids []string `json:"podids,omitempty"` - Privateinterface string `json:"privateinterface,omitempty"` - Provider string `json:"provider,omitempty"` - Publicinterface string `json:"publicinterface,omitempty"` -} - -type DeleteNetscalerLoadBalancerParams struct { - p map[string]interface{} -} - -func (p *DeleteNetscalerLoadBalancerParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["lbdeviceid"]; found { - u.Set("lbdeviceid", v.(string)) - } - return u -} - -func (p *DeleteNetscalerLoadBalancerParams) SetLbdeviceid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["lbdeviceid"] = v - return -} - -// You should always use this function to get a new DeleteNetscalerLoadBalancerParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewDeleteNetscalerLoadBalancerParams(lbdeviceid string) *DeleteNetscalerLoadBalancerParams { - p := &DeleteNetscalerLoadBalancerParams{} - p.p = make(map[string]interface{}) - p.p["lbdeviceid"] = lbdeviceid - return p -} - -// delete a netscaler load balancer device -func (s *LoadBalancerService) DeleteNetscalerLoadBalancer(p *DeleteNetscalerLoadBalancerParams) (*DeleteNetscalerLoadBalancerResponse, error) { - resp, err := s.cs.newRequest("deleteNetscalerLoadBalancer", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteNetscalerLoadBalancerResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteNetscalerLoadBalancerResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ConfigureNetscalerLoadBalancerParams struct { - p map[string]interface{} -} - -func (p *ConfigureNetscalerLoadBalancerParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["inline"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("inline", vv) - } - if v, found := p.p["lbdevicecapacity"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("lbdevicecapacity", vv) - } - if v, found := p.p["lbdevicededicated"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("lbdevicededicated", vv) - } - if v, found := p.p["lbdeviceid"]; found { - u.Set("lbdeviceid", v.(string)) - } - if v, found := p.p["podids"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("podids", vv) - } - return u -} - -func (p *ConfigureNetscalerLoadBalancerParams) SetInline(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["inline"] = v - return -} - -func (p *ConfigureNetscalerLoadBalancerParams) SetLbdevicecapacity(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["lbdevicecapacity"] = v - return -} - -func (p *ConfigureNetscalerLoadBalancerParams) SetLbdevicededicated(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["lbdevicededicated"] = v - return -} - -func (p *ConfigureNetscalerLoadBalancerParams) SetLbdeviceid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["lbdeviceid"] = v - return -} - -func (p *ConfigureNetscalerLoadBalancerParams) SetPodids(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["podids"] = v - return -} - -// You should always use this function to get a new ConfigureNetscalerLoadBalancerParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewConfigureNetscalerLoadBalancerParams(lbdeviceid string) *ConfigureNetscalerLoadBalancerParams { - p := &ConfigureNetscalerLoadBalancerParams{} - p.p = make(map[string]interface{}) - p.p["lbdeviceid"] = lbdeviceid - return p -} - -// configures a netscaler load balancer device -func (s *LoadBalancerService) ConfigureNetscalerLoadBalancer(p *ConfigureNetscalerLoadBalancerParams) (*ConfigureNetscalerLoadBalancerResponse, error) { - resp, err := s.cs.newRequest("configureNetscalerLoadBalancer", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ConfigureNetscalerLoadBalancerResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type ConfigureNetscalerLoadBalancerResponse struct { - JobID string `json:"jobid,omitempty"` - Gslbprovider bool `json:"gslbprovider,omitempty"` - Gslbproviderprivateip string `json:"gslbproviderprivateip,omitempty"` - Gslbproviderpublicip string `json:"gslbproviderpublicip,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isexclusivegslbprovider bool `json:"isexclusivegslbprovider,omitempty"` - Lbdevicecapacity int64 `json:"lbdevicecapacity,omitempty"` - Lbdevicededicated bool `json:"lbdevicededicated,omitempty"` - Lbdeviceid string `json:"lbdeviceid,omitempty"` - Lbdevicename string `json:"lbdevicename,omitempty"` - Lbdevicestate string `json:"lbdevicestate,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Podids []string `json:"podids,omitempty"` - Privateinterface string `json:"privateinterface,omitempty"` - Provider string `json:"provider,omitempty"` - Publicinterface string `json:"publicinterface,omitempty"` -} - -type ListNetscalerLoadBalancersParams struct { - p map[string]interface{} -} - -func (p *ListNetscalerLoadBalancersParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["lbdeviceid"]; found { - u.Set("lbdeviceid", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["physicalnetworkid"]; found { - u.Set("physicalnetworkid", v.(string)) - } - return u -} - -func (p *ListNetscalerLoadBalancersParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListNetscalerLoadBalancersParams) SetLbdeviceid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["lbdeviceid"] = v - return -} - -func (p *ListNetscalerLoadBalancersParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListNetscalerLoadBalancersParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListNetscalerLoadBalancersParams) SetPhysicalnetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["physicalnetworkid"] = v - return -} - -// You should always use this function to get a new ListNetscalerLoadBalancersParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewListNetscalerLoadBalancersParams() *ListNetscalerLoadBalancersParams { - p := &ListNetscalerLoadBalancersParams{} - p.p = make(map[string]interface{}) - return p -} - -// lists netscaler load balancer devices -func (s *LoadBalancerService) ListNetscalerLoadBalancers(p *ListNetscalerLoadBalancersParams) (*ListNetscalerLoadBalancersResponse, error) { - resp, err := s.cs.newRequest("listNetscalerLoadBalancers", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListNetscalerLoadBalancersResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListNetscalerLoadBalancersResponse struct { - Count int `json:"count"` - NetscalerLoadBalancers []*NetscalerLoadBalancer `json:"netscalerloadbalancer"` -} - -type NetscalerLoadBalancer struct { - Gslbprovider bool `json:"gslbprovider,omitempty"` - Gslbproviderprivateip string `json:"gslbproviderprivateip,omitempty"` - Gslbproviderpublicip string `json:"gslbproviderpublicip,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isexclusivegslbprovider bool `json:"isexclusivegslbprovider,omitempty"` - Lbdevicecapacity int64 `json:"lbdevicecapacity,omitempty"` - Lbdevicededicated bool `json:"lbdevicededicated,omitempty"` - Lbdeviceid string `json:"lbdeviceid,omitempty"` - Lbdevicename string `json:"lbdevicename,omitempty"` - Lbdevicestate string `json:"lbdevicestate,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Podids []string `json:"podids,omitempty"` - Privateinterface string `json:"privateinterface,omitempty"` - Provider string `json:"provider,omitempty"` - Publicinterface string `json:"publicinterface,omitempty"` -} - -type CreateGlobalLoadBalancerRuleParams struct { - p map[string]interface{} -} - -func (p *CreateGlobalLoadBalancerRuleParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["description"]; found { - u.Set("description", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["gslbdomainname"]; found { - u.Set("gslbdomainname", v.(string)) - } - if v, found := p.p["gslblbmethod"]; found { - u.Set("gslblbmethod", v.(string)) - } - if v, found := p.p["gslbservicetype"]; found { - u.Set("gslbservicetype", v.(string)) - } - if v, found := p.p["gslbstickysessionmethodname"]; found { - u.Set("gslbstickysessionmethodname", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["regionid"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("regionid", vv) - } - return u -} - -func (p *CreateGlobalLoadBalancerRuleParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *CreateGlobalLoadBalancerRuleParams) SetDescription(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["description"] = v - return -} - -func (p *CreateGlobalLoadBalancerRuleParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *CreateGlobalLoadBalancerRuleParams) SetGslbdomainname(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["gslbdomainname"] = v - return -} - -func (p *CreateGlobalLoadBalancerRuleParams) SetGslblbmethod(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["gslblbmethod"] = v - return -} - -func (p *CreateGlobalLoadBalancerRuleParams) SetGslbservicetype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["gslbservicetype"] = v - return -} - -func (p *CreateGlobalLoadBalancerRuleParams) SetGslbstickysessionmethodname(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["gslbstickysessionmethodname"] = v - return -} - -func (p *CreateGlobalLoadBalancerRuleParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *CreateGlobalLoadBalancerRuleParams) SetRegionid(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["regionid"] = v - return -} - -// You should always use this function to get a new CreateGlobalLoadBalancerRuleParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewCreateGlobalLoadBalancerRuleParams(gslbdomainname string, gslbservicetype string, name string, regionid int) *CreateGlobalLoadBalancerRuleParams { - p := &CreateGlobalLoadBalancerRuleParams{} - p.p = make(map[string]interface{}) - p.p["gslbdomainname"] = gslbdomainname - p.p["gslbservicetype"] = gslbservicetype - p.p["name"] = name - p.p["regionid"] = regionid - return p -} - -// Creates a global load balancer rule -func (s *LoadBalancerService) CreateGlobalLoadBalancerRule(p *CreateGlobalLoadBalancerRuleParams) (*CreateGlobalLoadBalancerRuleResponse, error) { - resp, err := s.cs.newRequest("createGlobalLoadBalancerRule", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateGlobalLoadBalancerRuleResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateGlobalLoadBalancerRuleResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Gslbdomainname string `json:"gslbdomainname,omitempty"` - Gslblbmethod string `json:"gslblbmethod,omitempty"` - Gslbservicetype string `json:"gslbservicetype,omitempty"` - Gslbstickysessionmethodname string `json:"gslbstickysessionmethodname,omitempty"` - Id string `json:"id,omitempty"` - Loadbalancerrule []struct { - Account string `json:"account,omitempty"` - Algorithm string `json:"algorithm,omitempty"` - Cidrlist string `json:"cidrlist,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Networkid string `json:"networkid,omitempty"` - Privateport string `json:"privateport,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Protocol string `json:"protocol,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - Publicport string `json:"publicport,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - } `json:"loadbalancerrule,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Regionid int `json:"regionid,omitempty"` -} - -type DeleteGlobalLoadBalancerRuleParams struct { - p map[string]interface{} -} - -func (p *DeleteGlobalLoadBalancerRuleParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteGlobalLoadBalancerRuleParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteGlobalLoadBalancerRuleParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewDeleteGlobalLoadBalancerRuleParams(id string) *DeleteGlobalLoadBalancerRuleParams { - p := &DeleteGlobalLoadBalancerRuleParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a global load balancer rule. -func (s *LoadBalancerService) DeleteGlobalLoadBalancerRule(p *DeleteGlobalLoadBalancerRuleParams) (*DeleteGlobalLoadBalancerRuleResponse, error) { - resp, err := s.cs.newRequest("deleteGlobalLoadBalancerRule", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteGlobalLoadBalancerRuleResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteGlobalLoadBalancerRuleResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type UpdateGlobalLoadBalancerRuleParams struct { - p map[string]interface{} -} - -func (p *UpdateGlobalLoadBalancerRuleParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["description"]; found { - u.Set("description", v.(string)) - } - if v, found := p.p["gslblbmethod"]; found { - u.Set("gslblbmethod", v.(string)) - } - if v, found := p.p["gslbstickysessionmethodname"]; found { - u.Set("gslbstickysessionmethodname", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *UpdateGlobalLoadBalancerRuleParams) SetDescription(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["description"] = v - return -} - -func (p *UpdateGlobalLoadBalancerRuleParams) SetGslblbmethod(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["gslblbmethod"] = v - return -} - -func (p *UpdateGlobalLoadBalancerRuleParams) SetGslbstickysessionmethodname(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["gslbstickysessionmethodname"] = v - return -} - -func (p *UpdateGlobalLoadBalancerRuleParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new UpdateGlobalLoadBalancerRuleParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewUpdateGlobalLoadBalancerRuleParams(id string) *UpdateGlobalLoadBalancerRuleParams { - p := &UpdateGlobalLoadBalancerRuleParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// update global load balancer rules. -func (s *LoadBalancerService) UpdateGlobalLoadBalancerRule(p *UpdateGlobalLoadBalancerRuleParams) (*UpdateGlobalLoadBalancerRuleResponse, error) { - resp, err := s.cs.newRequest("updateGlobalLoadBalancerRule", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateGlobalLoadBalancerRuleResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateGlobalLoadBalancerRuleResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Gslbdomainname string `json:"gslbdomainname,omitempty"` - Gslblbmethod string `json:"gslblbmethod,omitempty"` - Gslbservicetype string `json:"gslbservicetype,omitempty"` - Gslbstickysessionmethodname string `json:"gslbstickysessionmethodname,omitempty"` - Id string `json:"id,omitempty"` - Loadbalancerrule []struct { - Account string `json:"account,omitempty"` - Algorithm string `json:"algorithm,omitempty"` - Cidrlist string `json:"cidrlist,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Networkid string `json:"networkid,omitempty"` - Privateport string `json:"privateport,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Protocol string `json:"protocol,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - Publicport string `json:"publicport,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - } `json:"loadbalancerrule,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Regionid int `json:"regionid,omitempty"` -} - -type ListGlobalLoadBalancerRulesParams struct { - p map[string]interface{} -} - -func (p *ListGlobalLoadBalancerRulesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["regionid"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("regionid", vv) - } - if v, found := p.p["tags"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("tags[%d].key", i), k) - u.Set(fmt.Sprintf("tags[%d].value", i), vv) - i++ - } - } - return u -} - -func (p *ListGlobalLoadBalancerRulesParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListGlobalLoadBalancerRulesParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListGlobalLoadBalancerRulesParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListGlobalLoadBalancerRulesParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListGlobalLoadBalancerRulesParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListGlobalLoadBalancerRulesParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListGlobalLoadBalancerRulesParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListGlobalLoadBalancerRulesParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListGlobalLoadBalancerRulesParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListGlobalLoadBalancerRulesParams) SetRegionid(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["regionid"] = v - return -} - -func (p *ListGlobalLoadBalancerRulesParams) SetTags(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tags"] = v - return -} - -// You should always use this function to get a new ListGlobalLoadBalancerRulesParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewListGlobalLoadBalancerRulesParams() *ListGlobalLoadBalancerRulesParams { - p := &ListGlobalLoadBalancerRulesParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *LoadBalancerService) GetGlobalLoadBalancerRuleID(keyword string, opts ...OptionFunc) (string, int, error) { - p := &ListGlobalLoadBalancerRulesParams{} - p.p = make(map[string]interface{}) - - p.p["keyword"] = keyword - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListGlobalLoadBalancerRules(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", keyword, l) - } - - if l.Count == 1 { - return l.GlobalLoadBalancerRules[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.GlobalLoadBalancerRules { - if v.Name == keyword { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *LoadBalancerService) GetGlobalLoadBalancerRuleByName(name string, opts ...OptionFunc) (*GlobalLoadBalancerRule, int, error) { - id, count, err := s.GetGlobalLoadBalancerRuleID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetGlobalLoadBalancerRuleByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *LoadBalancerService) GetGlobalLoadBalancerRuleByID(id string, opts ...OptionFunc) (*GlobalLoadBalancerRule, int, error) { - p := &ListGlobalLoadBalancerRulesParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListGlobalLoadBalancerRules(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.GlobalLoadBalancerRules[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for GlobalLoadBalancerRule UUID: %s!", id) -} - -// Lists load balancer rules. -func (s *LoadBalancerService) ListGlobalLoadBalancerRules(p *ListGlobalLoadBalancerRulesParams) (*ListGlobalLoadBalancerRulesResponse, error) { - resp, err := s.cs.newRequest("listGlobalLoadBalancerRules", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListGlobalLoadBalancerRulesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListGlobalLoadBalancerRulesResponse struct { - Count int `json:"count"` - GlobalLoadBalancerRules []*GlobalLoadBalancerRule `json:"globalloadbalancerrule"` -} - -type GlobalLoadBalancerRule struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Gslbdomainname string `json:"gslbdomainname,omitempty"` - Gslblbmethod string `json:"gslblbmethod,omitempty"` - Gslbservicetype string `json:"gslbservicetype,omitempty"` - Gslbstickysessionmethodname string `json:"gslbstickysessionmethodname,omitempty"` - Id string `json:"id,omitempty"` - Loadbalancerrule []struct { - Account string `json:"account,omitempty"` - Algorithm string `json:"algorithm,omitempty"` - Cidrlist string `json:"cidrlist,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Networkid string `json:"networkid,omitempty"` - Privateport string `json:"privateport,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Protocol string `json:"protocol,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - Publicport string `json:"publicport,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - } `json:"loadbalancerrule,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Regionid int `json:"regionid,omitempty"` -} - -type AssignToGlobalLoadBalancerRuleParams struct { - p map[string]interface{} -} - -func (p *AssignToGlobalLoadBalancerRuleParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["gslblbruleweightsmap"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("gslblbruleweightsmap[%d].key", i), k) - u.Set(fmt.Sprintf("gslblbruleweightsmap[%d].value", i), vv) - i++ - } - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["loadbalancerrulelist"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("loadbalancerrulelist", vv) - } - return u -} - -func (p *AssignToGlobalLoadBalancerRuleParams) SetGslblbruleweightsmap(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["gslblbruleweightsmap"] = v - return -} - -func (p *AssignToGlobalLoadBalancerRuleParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *AssignToGlobalLoadBalancerRuleParams) SetLoadbalancerrulelist(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["loadbalancerrulelist"] = v - return -} - -// You should always use this function to get a new AssignToGlobalLoadBalancerRuleParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewAssignToGlobalLoadBalancerRuleParams(id string, loadbalancerrulelist []string) *AssignToGlobalLoadBalancerRuleParams { - p := &AssignToGlobalLoadBalancerRuleParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - p.p["loadbalancerrulelist"] = loadbalancerrulelist - return p -} - -// Assign load balancer rule or list of load balancer rules to a global load balancer rules. -func (s *LoadBalancerService) AssignToGlobalLoadBalancerRule(p *AssignToGlobalLoadBalancerRuleParams) (*AssignToGlobalLoadBalancerRuleResponse, error) { - resp, err := s.cs.newRequest("assignToGlobalLoadBalancerRule", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AssignToGlobalLoadBalancerRuleResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type AssignToGlobalLoadBalancerRuleResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type RemoveFromGlobalLoadBalancerRuleParams struct { - p map[string]interface{} -} - -func (p *RemoveFromGlobalLoadBalancerRuleParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["loadbalancerrulelist"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("loadbalancerrulelist", vv) - } - return u -} - -func (p *RemoveFromGlobalLoadBalancerRuleParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *RemoveFromGlobalLoadBalancerRuleParams) SetLoadbalancerrulelist(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["loadbalancerrulelist"] = v - return -} - -// You should always use this function to get a new RemoveFromGlobalLoadBalancerRuleParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewRemoveFromGlobalLoadBalancerRuleParams(id string, loadbalancerrulelist []string) *RemoveFromGlobalLoadBalancerRuleParams { - p := &RemoveFromGlobalLoadBalancerRuleParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - p.p["loadbalancerrulelist"] = loadbalancerrulelist - return p -} - -// Removes a load balancer rule association with global load balancer rule -func (s *LoadBalancerService) RemoveFromGlobalLoadBalancerRule(p *RemoveFromGlobalLoadBalancerRuleParams) (*RemoveFromGlobalLoadBalancerRuleResponse, error) { - resp, err := s.cs.newRequest("removeFromGlobalLoadBalancerRule", p.toURLValues()) - if err != nil { - return nil, err - } - - var r RemoveFromGlobalLoadBalancerRuleResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type RemoveFromGlobalLoadBalancerRuleResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type CreateLoadBalancerParams struct { - p map[string]interface{} -} - -func (p *CreateLoadBalancerParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["algorithm"]; found { - u.Set("algorithm", v.(string)) - } - if v, found := p.p["description"]; found { - u.Set("description", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["instanceport"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("instanceport", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["networkid"]; found { - u.Set("networkid", v.(string)) - } - if v, found := p.p["scheme"]; found { - u.Set("scheme", v.(string)) - } - if v, found := p.p["sourceipaddress"]; found { - u.Set("sourceipaddress", v.(string)) - } - if v, found := p.p["sourceipaddressnetworkid"]; found { - u.Set("sourceipaddressnetworkid", v.(string)) - } - if v, found := p.p["sourceport"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("sourceport", vv) - } - return u -} - -func (p *CreateLoadBalancerParams) SetAlgorithm(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["algorithm"] = v - return -} - -func (p *CreateLoadBalancerParams) SetDescription(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["description"] = v - return -} - -func (p *CreateLoadBalancerParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *CreateLoadBalancerParams) SetInstanceport(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["instanceport"] = v - return -} - -func (p *CreateLoadBalancerParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *CreateLoadBalancerParams) SetNetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkid"] = v - return -} - -func (p *CreateLoadBalancerParams) SetScheme(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["scheme"] = v - return -} - -func (p *CreateLoadBalancerParams) SetSourceipaddress(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["sourceipaddress"] = v - return -} - -func (p *CreateLoadBalancerParams) SetSourceipaddressnetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["sourceipaddressnetworkid"] = v - return -} - -func (p *CreateLoadBalancerParams) SetSourceport(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["sourceport"] = v - return -} - -// You should always use this function to get a new CreateLoadBalancerParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewCreateLoadBalancerParams(algorithm string, instanceport int, name string, networkid string, scheme string, sourceipaddressnetworkid string, sourceport int) *CreateLoadBalancerParams { - p := &CreateLoadBalancerParams{} - p.p = make(map[string]interface{}) - p.p["algorithm"] = algorithm - p.p["instanceport"] = instanceport - p.p["name"] = name - p.p["networkid"] = networkid - p.p["scheme"] = scheme - p.p["sourceipaddressnetworkid"] = sourceipaddressnetworkid - p.p["sourceport"] = sourceport - return p -} - -// Creates a load balancer -func (s *LoadBalancerService) CreateLoadBalancer(p *CreateLoadBalancerParams) (*CreateLoadBalancerResponse, error) { - resp, err := s.cs.newRequest("createLoadBalancer", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateLoadBalancerResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateLoadBalancerResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Algorithm string `json:"algorithm,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Loadbalancerinstance []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Name string `json:"name,omitempty"` - State string `json:"state,omitempty"` - } `json:"loadbalancerinstance,omitempty"` - Loadbalancerrule []struct { - Instanceport int `json:"instanceport,omitempty"` - Sourceport int `json:"sourceport,omitempty"` - State string `json:"state,omitempty"` - } `json:"loadbalancerrule,omitempty"` - Name string `json:"name,omitempty"` - Networkid string `json:"networkid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Sourceipaddress string `json:"sourceipaddress,omitempty"` - Sourceipaddressnetworkid string `json:"sourceipaddressnetworkid,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` -} - -type ListLoadBalancersParams struct { - p map[string]interface{} -} - -func (p *ListLoadBalancersParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["networkid"]; found { - u.Set("networkid", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["scheme"]; found { - u.Set("scheme", v.(string)) - } - if v, found := p.p["sourceipaddress"]; found { - u.Set("sourceipaddress", v.(string)) - } - if v, found := p.p["sourceipaddressnetworkid"]; found { - u.Set("sourceipaddressnetworkid", v.(string)) - } - if v, found := p.p["tags"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("tags[%d].key", i), k) - u.Set(fmt.Sprintf("tags[%d].value", i), vv) - i++ - } - } - return u -} - -func (p *ListLoadBalancersParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListLoadBalancersParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListLoadBalancersParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *ListLoadBalancersParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListLoadBalancersParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListLoadBalancersParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListLoadBalancersParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListLoadBalancersParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListLoadBalancersParams) SetNetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkid"] = v - return -} - -func (p *ListLoadBalancersParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListLoadBalancersParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListLoadBalancersParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListLoadBalancersParams) SetScheme(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["scheme"] = v - return -} - -func (p *ListLoadBalancersParams) SetSourceipaddress(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["sourceipaddress"] = v - return -} - -func (p *ListLoadBalancersParams) SetSourceipaddressnetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["sourceipaddressnetworkid"] = v - return -} - -func (p *ListLoadBalancersParams) SetTags(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tags"] = v - return -} - -// You should always use this function to get a new ListLoadBalancersParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewListLoadBalancersParams() *ListLoadBalancersParams { - p := &ListLoadBalancersParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *LoadBalancerService) GetLoadBalancerID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListLoadBalancersParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListLoadBalancers(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.LoadBalancers[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.LoadBalancers { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *LoadBalancerService) GetLoadBalancerByName(name string, opts ...OptionFunc) (*LoadBalancer, int, error) { - id, count, err := s.GetLoadBalancerID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetLoadBalancerByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *LoadBalancerService) GetLoadBalancerByID(id string, opts ...OptionFunc) (*LoadBalancer, int, error) { - p := &ListLoadBalancersParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListLoadBalancers(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.LoadBalancers[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for LoadBalancer UUID: %s!", id) -} - -// Lists load balancers -func (s *LoadBalancerService) ListLoadBalancers(p *ListLoadBalancersParams) (*ListLoadBalancersResponse, error) { - resp, err := s.cs.newRequest("listLoadBalancers", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListLoadBalancersResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListLoadBalancersResponse struct { - Count int `json:"count"` - LoadBalancers []*LoadBalancer `json:"loadbalancer"` -} - -type LoadBalancer struct { - Account string `json:"account,omitempty"` - Algorithm string `json:"algorithm,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Loadbalancerinstance []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Name string `json:"name,omitempty"` - State string `json:"state,omitempty"` - } `json:"loadbalancerinstance,omitempty"` - Loadbalancerrule []struct { - Instanceport int `json:"instanceport,omitempty"` - Sourceport int `json:"sourceport,omitempty"` - State string `json:"state,omitempty"` - } `json:"loadbalancerrule,omitempty"` - Name string `json:"name,omitempty"` - Networkid string `json:"networkid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Sourceipaddress string `json:"sourceipaddress,omitempty"` - Sourceipaddressnetworkid string `json:"sourceipaddressnetworkid,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` -} - -type DeleteLoadBalancerParams struct { - p map[string]interface{} -} - -func (p *DeleteLoadBalancerParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteLoadBalancerParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteLoadBalancerParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewDeleteLoadBalancerParams(id string) *DeleteLoadBalancerParams { - p := &DeleteLoadBalancerParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a load balancer -func (s *LoadBalancerService) DeleteLoadBalancer(p *DeleteLoadBalancerParams) (*DeleteLoadBalancerResponse, error) { - resp, err := s.cs.newRequest("deleteLoadBalancer", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteLoadBalancerResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteLoadBalancerResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type UpdateLoadBalancerParams struct { - p map[string]interface{} -} - -func (p *UpdateLoadBalancerParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["customid"]; found { - u.Set("customid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *UpdateLoadBalancerParams) SetCustomid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["customid"] = v - return -} - -func (p *UpdateLoadBalancerParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *UpdateLoadBalancerParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new UpdateLoadBalancerParams instance, -// as then you are sure you have configured all required params -func (s *LoadBalancerService) NewUpdateLoadBalancerParams(id string) *UpdateLoadBalancerParams { - p := &UpdateLoadBalancerParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates a load balancer -func (s *LoadBalancerService) UpdateLoadBalancer(p *UpdateLoadBalancerParams) (*UpdateLoadBalancerResponse, error) { - resp, err := s.cs.newRequest("updateLoadBalancer", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateLoadBalancerResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateLoadBalancerResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Algorithm string `json:"algorithm,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Loadbalancerinstance []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Name string `json:"name,omitempty"` - State string `json:"state,omitempty"` - } `json:"loadbalancerinstance,omitempty"` - Loadbalancerrule []struct { - Instanceport int `json:"instanceport,omitempty"` - Sourceport int `json:"sourceport,omitempty"` - State string `json:"state,omitempty"` - } `json:"loadbalancerrule,omitempty"` - Name string `json:"name,omitempty"` - Networkid string `json:"networkid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Sourceipaddress string `json:"sourceipaddress,omitempty"` - Sourceipaddressnetworkid string `json:"sourceipaddressnetworkid,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/NATService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/NATService.go deleted file mode 100644 index daaf10edeb6..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/NATService.go +++ /dev/null @@ -1,631 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type EnableStaticNatParams struct { - p map[string]interface{} -} - -func (p *EnableStaticNatParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["ipaddressid"]; found { - u.Set("ipaddressid", v.(string)) - } - if v, found := p.p["networkid"]; found { - u.Set("networkid", v.(string)) - } - if v, found := p.p["virtualmachineid"]; found { - u.Set("virtualmachineid", v.(string)) - } - if v, found := p.p["vmguestip"]; found { - u.Set("vmguestip", v.(string)) - } - return u -} - -func (p *EnableStaticNatParams) SetIpaddressid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ipaddressid"] = v - return -} - -func (p *EnableStaticNatParams) SetNetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkid"] = v - return -} - -func (p *EnableStaticNatParams) SetVirtualmachineid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["virtualmachineid"] = v - return -} - -func (p *EnableStaticNatParams) SetVmguestip(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vmguestip"] = v - return -} - -// You should always use this function to get a new EnableStaticNatParams instance, -// as then you are sure you have configured all required params -func (s *NATService) NewEnableStaticNatParams(ipaddressid string, virtualmachineid string) *EnableStaticNatParams { - p := &EnableStaticNatParams{} - p.p = make(map[string]interface{}) - p.p["ipaddressid"] = ipaddressid - p.p["virtualmachineid"] = virtualmachineid - return p -} - -// Enables static NAT for given IP address -func (s *NATService) EnableStaticNat(p *EnableStaticNatParams) (*EnableStaticNatResponse, error) { - resp, err := s.cs.newRequest("enableStaticNat", p.toURLValues()) - if err != nil { - return nil, err - } - - var r EnableStaticNatResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type EnableStaticNatResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} - -type CreateIpForwardingRuleParams struct { - p map[string]interface{} -} - -func (p *CreateIpForwardingRuleParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["cidrlist"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("cidrlist", vv) - } - if v, found := p.p["endport"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("endport", vv) - } - if v, found := p.p["ipaddressid"]; found { - u.Set("ipaddressid", v.(string)) - } - if v, found := p.p["openfirewall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("openfirewall", vv) - } - if v, found := p.p["protocol"]; found { - u.Set("protocol", v.(string)) - } - if v, found := p.p["startport"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("startport", vv) - } - return u -} - -func (p *CreateIpForwardingRuleParams) SetCidrlist(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["cidrlist"] = v - return -} - -func (p *CreateIpForwardingRuleParams) SetEndport(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["endport"] = v - return -} - -func (p *CreateIpForwardingRuleParams) SetIpaddressid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ipaddressid"] = v - return -} - -func (p *CreateIpForwardingRuleParams) SetOpenfirewall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["openfirewall"] = v - return -} - -func (p *CreateIpForwardingRuleParams) SetProtocol(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["protocol"] = v - return -} - -func (p *CreateIpForwardingRuleParams) SetStartport(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["startport"] = v - return -} - -// You should always use this function to get a new CreateIpForwardingRuleParams instance, -// as then you are sure you have configured all required params -func (s *NATService) NewCreateIpForwardingRuleParams(ipaddressid string, protocol string, startport int) *CreateIpForwardingRuleParams { - p := &CreateIpForwardingRuleParams{} - p.p = make(map[string]interface{}) - p.p["ipaddressid"] = ipaddressid - p.p["protocol"] = protocol - p.p["startport"] = startport - return p -} - -// Creates an IP forwarding rule -func (s *NATService) CreateIpForwardingRule(p *CreateIpForwardingRuleParams) (*CreateIpForwardingRuleResponse, error) { - resp, err := s.cs.newRequest("createIpForwardingRule", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateIpForwardingRuleResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateIpForwardingRuleResponse struct { - JobID string `json:"jobid,omitempty"` - Cidrlist string `json:"cidrlist,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Ipaddressid string `json:"ipaddressid,omitempty"` - Networkid string `json:"networkid,omitempty"` - Privateendport string `json:"privateendport,omitempty"` - Privateport string `json:"privateport,omitempty"` - Protocol string `json:"protocol,omitempty"` - Publicendport string `json:"publicendport,omitempty"` - Publicport string `json:"publicport,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinedisplayname string `json:"virtualmachinedisplayname,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - Virtualmachinename string `json:"virtualmachinename,omitempty"` - Vmguestip string `json:"vmguestip,omitempty"` -} - -type DeleteIpForwardingRuleParams struct { - p map[string]interface{} -} - -func (p *DeleteIpForwardingRuleParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteIpForwardingRuleParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteIpForwardingRuleParams instance, -// as then you are sure you have configured all required params -func (s *NATService) NewDeleteIpForwardingRuleParams(id string) *DeleteIpForwardingRuleParams { - p := &DeleteIpForwardingRuleParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes an IP forwarding rule -func (s *NATService) DeleteIpForwardingRule(p *DeleteIpForwardingRuleParams) (*DeleteIpForwardingRuleResponse, error) { - resp, err := s.cs.newRequest("deleteIpForwardingRule", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteIpForwardingRuleResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteIpForwardingRuleResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListIpForwardingRulesParams struct { - p map[string]interface{} -} - -func (p *ListIpForwardingRulesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["ipaddressid"]; found { - u.Set("ipaddressid", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["virtualmachineid"]; found { - u.Set("virtualmachineid", v.(string)) - } - return u -} - -func (p *ListIpForwardingRulesParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListIpForwardingRulesParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListIpForwardingRulesParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListIpForwardingRulesParams) SetIpaddressid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ipaddressid"] = v - return -} - -func (p *ListIpForwardingRulesParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListIpForwardingRulesParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListIpForwardingRulesParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListIpForwardingRulesParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListIpForwardingRulesParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListIpForwardingRulesParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListIpForwardingRulesParams) SetVirtualmachineid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["virtualmachineid"] = v - return -} - -// You should always use this function to get a new ListIpForwardingRulesParams instance, -// as then you are sure you have configured all required params -func (s *NATService) NewListIpForwardingRulesParams() *ListIpForwardingRulesParams { - p := &ListIpForwardingRulesParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *NATService) GetIpForwardingRuleByID(id string, opts ...OptionFunc) (*IpForwardingRule, int, error) { - p := &ListIpForwardingRulesParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListIpForwardingRules(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.IpForwardingRules[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for IpForwardingRule UUID: %s!", id) -} - -// List the IP forwarding rules -func (s *NATService) ListIpForwardingRules(p *ListIpForwardingRulesParams) (*ListIpForwardingRulesResponse, error) { - resp, err := s.cs.newRequest("listIpForwardingRules", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListIpForwardingRulesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListIpForwardingRulesResponse struct { - Count int `json:"count"` - IpForwardingRules []*IpForwardingRule `json:"ipforwardingrule"` -} - -type IpForwardingRule struct { - Cidrlist string `json:"cidrlist,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Ipaddressid string `json:"ipaddressid,omitempty"` - Networkid string `json:"networkid,omitempty"` - Privateendport string `json:"privateendport,omitempty"` - Privateport string `json:"privateport,omitempty"` - Protocol string `json:"protocol,omitempty"` - Publicendport string `json:"publicendport,omitempty"` - Publicport string `json:"publicport,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinedisplayname string `json:"virtualmachinedisplayname,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - Virtualmachinename string `json:"virtualmachinename,omitempty"` - Vmguestip string `json:"vmguestip,omitempty"` -} - -type DisableStaticNatParams struct { - p map[string]interface{} -} - -func (p *DisableStaticNatParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["ipaddressid"]; found { - u.Set("ipaddressid", v.(string)) - } - return u -} - -func (p *DisableStaticNatParams) SetIpaddressid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ipaddressid"] = v - return -} - -// You should always use this function to get a new DisableStaticNatParams instance, -// as then you are sure you have configured all required params -func (s *NATService) NewDisableStaticNatParams(ipaddressid string) *DisableStaticNatParams { - p := &DisableStaticNatParams{} - p.p = make(map[string]interface{}) - p.p["ipaddressid"] = ipaddressid - return p -} - -// Disables static rule for given IP address -func (s *NATService) DisableStaticNat(p *DisableStaticNatParams) (*DisableStaticNatResponse, error) { - resp, err := s.cs.newRequest("disableStaticNat", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DisableStaticNatResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DisableStaticNatResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/NetworkACLService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/NetworkACLService.go deleted file mode 100644 index 8a53ddf6ed0..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/NetworkACLService.go +++ /dev/null @@ -1,1458 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type CreateNetworkACLParams struct { - p map[string]interface{} -} - -func (p *CreateNetworkACLParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["aclid"]; found { - u.Set("aclid", v.(string)) - } - if v, found := p.p["action"]; found { - u.Set("action", v.(string)) - } - if v, found := p.p["cidrlist"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("cidrlist", vv) - } - if v, found := p.p["endport"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("endport", vv) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["icmpcode"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("icmpcode", vv) - } - if v, found := p.p["icmptype"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("icmptype", vv) - } - if v, found := p.p["networkid"]; found { - u.Set("networkid", v.(string)) - } - if v, found := p.p["number"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("number", vv) - } - if v, found := p.p["protocol"]; found { - u.Set("protocol", v.(string)) - } - if v, found := p.p["startport"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("startport", vv) - } - if v, found := p.p["traffictype"]; found { - u.Set("traffictype", v.(string)) - } - return u -} - -func (p *CreateNetworkACLParams) SetAclid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["aclid"] = v - return -} - -func (p *CreateNetworkACLParams) SetAction(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["action"] = v - return -} - -func (p *CreateNetworkACLParams) SetCidrlist(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["cidrlist"] = v - return -} - -func (p *CreateNetworkACLParams) SetEndport(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["endport"] = v - return -} - -func (p *CreateNetworkACLParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *CreateNetworkACLParams) SetIcmpcode(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["icmpcode"] = v - return -} - -func (p *CreateNetworkACLParams) SetIcmptype(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["icmptype"] = v - return -} - -func (p *CreateNetworkACLParams) SetNetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkid"] = v - return -} - -func (p *CreateNetworkACLParams) SetNumber(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["number"] = v - return -} - -func (p *CreateNetworkACLParams) SetProtocol(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["protocol"] = v - return -} - -func (p *CreateNetworkACLParams) SetStartport(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["startport"] = v - return -} - -func (p *CreateNetworkACLParams) SetTraffictype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["traffictype"] = v - return -} - -// You should always use this function to get a new CreateNetworkACLParams instance, -// as then you are sure you have configured all required params -func (s *NetworkACLService) NewCreateNetworkACLParams(protocol string) *CreateNetworkACLParams { - p := &CreateNetworkACLParams{} - p.p = make(map[string]interface{}) - p.p["protocol"] = protocol - return p -} - -// Creates a ACL rule in the given network (the network has to belong to VPC) -func (s *NetworkACLService) CreateNetworkACL(p *CreateNetworkACLParams) (*CreateNetworkACLResponse, error) { - resp, err := s.cs.newRequest("createNetworkACL", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateNetworkACLResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateNetworkACLResponse struct { - JobID string `json:"jobid,omitempty"` - Aclid string `json:"aclid,omitempty"` - Action string `json:"action,omitempty"` - Cidrlist string `json:"cidrlist,omitempty"` - Endport string `json:"endport,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Id string `json:"id,omitempty"` - Number int `json:"number,omitempty"` - Protocol string `json:"protocol,omitempty"` - Startport string `json:"startport,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Traffictype string `json:"traffictype,omitempty"` -} - -type UpdateNetworkACLItemParams struct { - p map[string]interface{} -} - -func (p *UpdateNetworkACLItemParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["action"]; found { - u.Set("action", v.(string)) - } - if v, found := p.p["cidrlist"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("cidrlist", vv) - } - if v, found := p.p["customid"]; found { - u.Set("customid", v.(string)) - } - if v, found := p.p["endport"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("endport", vv) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["icmpcode"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("icmpcode", vv) - } - if v, found := p.p["icmptype"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("icmptype", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["number"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("number", vv) - } - if v, found := p.p["protocol"]; found { - u.Set("protocol", v.(string)) - } - if v, found := p.p["startport"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("startport", vv) - } - if v, found := p.p["traffictype"]; found { - u.Set("traffictype", v.(string)) - } - return u -} - -func (p *UpdateNetworkACLItemParams) SetAction(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["action"] = v - return -} - -func (p *UpdateNetworkACLItemParams) SetCidrlist(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["cidrlist"] = v - return -} - -func (p *UpdateNetworkACLItemParams) SetCustomid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["customid"] = v - return -} - -func (p *UpdateNetworkACLItemParams) SetEndport(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["endport"] = v - return -} - -func (p *UpdateNetworkACLItemParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *UpdateNetworkACLItemParams) SetIcmpcode(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["icmpcode"] = v - return -} - -func (p *UpdateNetworkACLItemParams) SetIcmptype(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["icmptype"] = v - return -} - -func (p *UpdateNetworkACLItemParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateNetworkACLItemParams) SetNumber(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["number"] = v - return -} - -func (p *UpdateNetworkACLItemParams) SetProtocol(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["protocol"] = v - return -} - -func (p *UpdateNetworkACLItemParams) SetStartport(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["startport"] = v - return -} - -func (p *UpdateNetworkACLItemParams) SetTraffictype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["traffictype"] = v - return -} - -// You should always use this function to get a new UpdateNetworkACLItemParams instance, -// as then you are sure you have configured all required params -func (s *NetworkACLService) NewUpdateNetworkACLItemParams(id string) *UpdateNetworkACLItemParams { - p := &UpdateNetworkACLItemParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates ACL item with specified ID -func (s *NetworkACLService) UpdateNetworkACLItem(p *UpdateNetworkACLItemParams) (*UpdateNetworkACLItemResponse, error) { - resp, err := s.cs.newRequest("updateNetworkACLItem", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateNetworkACLItemResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateNetworkACLItemResponse struct { - JobID string `json:"jobid,omitempty"` - Aclid string `json:"aclid,omitempty"` - Action string `json:"action,omitempty"` - Cidrlist string `json:"cidrlist,omitempty"` - Endport string `json:"endport,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Id string `json:"id,omitempty"` - Number int `json:"number,omitempty"` - Protocol string `json:"protocol,omitempty"` - Startport string `json:"startport,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Traffictype string `json:"traffictype,omitempty"` -} - -type DeleteNetworkACLParams struct { - p map[string]interface{} -} - -func (p *DeleteNetworkACLParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteNetworkACLParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteNetworkACLParams instance, -// as then you are sure you have configured all required params -func (s *NetworkACLService) NewDeleteNetworkACLParams(id string) *DeleteNetworkACLParams { - p := &DeleteNetworkACLParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a network ACL -func (s *NetworkACLService) DeleteNetworkACL(p *DeleteNetworkACLParams) (*DeleteNetworkACLResponse, error) { - resp, err := s.cs.newRequest("deleteNetworkACL", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteNetworkACLResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteNetworkACLResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListNetworkACLsParams struct { - p map[string]interface{} -} - -func (p *ListNetworkACLsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["aclid"]; found { - u.Set("aclid", v.(string)) - } - if v, found := p.p["action"]; found { - u.Set("action", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["networkid"]; found { - u.Set("networkid", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["protocol"]; found { - u.Set("protocol", v.(string)) - } - if v, found := p.p["tags"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("tags[%d].key", i), k) - u.Set(fmt.Sprintf("tags[%d].value", i), vv) - i++ - } - } - if v, found := p.p["traffictype"]; found { - u.Set("traffictype", v.(string)) - } - return u -} - -func (p *ListNetworkACLsParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListNetworkACLsParams) SetAclid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["aclid"] = v - return -} - -func (p *ListNetworkACLsParams) SetAction(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["action"] = v - return -} - -func (p *ListNetworkACLsParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListNetworkACLsParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *ListNetworkACLsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListNetworkACLsParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListNetworkACLsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListNetworkACLsParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListNetworkACLsParams) SetNetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkid"] = v - return -} - -func (p *ListNetworkACLsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListNetworkACLsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListNetworkACLsParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListNetworkACLsParams) SetProtocol(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["protocol"] = v - return -} - -func (p *ListNetworkACLsParams) SetTags(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tags"] = v - return -} - -func (p *ListNetworkACLsParams) SetTraffictype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["traffictype"] = v - return -} - -// You should always use this function to get a new ListNetworkACLsParams instance, -// as then you are sure you have configured all required params -func (s *NetworkACLService) NewListNetworkACLsParams() *ListNetworkACLsParams { - p := &ListNetworkACLsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *NetworkACLService) GetNetworkACLByID(id string, opts ...OptionFunc) (*NetworkACL, int, error) { - p := &ListNetworkACLsParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListNetworkACLs(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.NetworkACLs[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for NetworkACL UUID: %s!", id) -} - -// Lists all network ACL items -func (s *NetworkACLService) ListNetworkACLs(p *ListNetworkACLsParams) (*ListNetworkACLsResponse, error) { - resp, err := s.cs.newRequest("listNetworkACLs", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListNetworkACLsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListNetworkACLsResponse struct { - Count int `json:"count"` - NetworkACLs []*NetworkACL `json:"networkacl"` -} - -type NetworkACL struct { - Aclid string `json:"aclid,omitempty"` - Action string `json:"action,omitempty"` - Cidrlist string `json:"cidrlist,omitempty"` - Endport string `json:"endport,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Id string `json:"id,omitempty"` - Number int `json:"number,omitempty"` - Protocol string `json:"protocol,omitempty"` - Startport string `json:"startport,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Traffictype string `json:"traffictype,omitempty"` -} - -type CreateNetworkACLListParams struct { - p map[string]interface{} -} - -func (p *CreateNetworkACLListParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["description"]; found { - u.Set("description", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["vpcid"]; found { - u.Set("vpcid", v.(string)) - } - return u -} - -func (p *CreateNetworkACLListParams) SetDescription(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["description"] = v - return -} - -func (p *CreateNetworkACLListParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *CreateNetworkACLListParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *CreateNetworkACLListParams) SetVpcid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vpcid"] = v - return -} - -// You should always use this function to get a new CreateNetworkACLListParams instance, -// as then you are sure you have configured all required params -func (s *NetworkACLService) NewCreateNetworkACLListParams(name string, vpcid string) *CreateNetworkACLListParams { - p := &CreateNetworkACLListParams{} - p.p = make(map[string]interface{}) - p.p["name"] = name - p.p["vpcid"] = vpcid - return p -} - -// Creates a network ACL for the given VPC -func (s *NetworkACLService) CreateNetworkACLList(p *CreateNetworkACLListParams) (*CreateNetworkACLListResponse, error) { - resp, err := s.cs.newRequest("createNetworkACLList", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateNetworkACLListResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateNetworkACLListResponse struct { - JobID string `json:"jobid,omitempty"` - Description string `json:"description,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Vpcid string `json:"vpcid,omitempty"` -} - -type DeleteNetworkACLListParams struct { - p map[string]interface{} -} - -func (p *DeleteNetworkACLListParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteNetworkACLListParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteNetworkACLListParams instance, -// as then you are sure you have configured all required params -func (s *NetworkACLService) NewDeleteNetworkACLListParams(id string) *DeleteNetworkACLListParams { - p := &DeleteNetworkACLListParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a network ACL -func (s *NetworkACLService) DeleteNetworkACLList(p *DeleteNetworkACLListParams) (*DeleteNetworkACLListResponse, error) { - resp, err := s.cs.newRequest("deleteNetworkACLList", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteNetworkACLListResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteNetworkACLListResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ReplaceNetworkACLListParams struct { - p map[string]interface{} -} - -func (p *ReplaceNetworkACLListParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["aclid"]; found { - u.Set("aclid", v.(string)) - } - if v, found := p.p["gatewayid"]; found { - u.Set("gatewayid", v.(string)) - } - if v, found := p.p["networkid"]; found { - u.Set("networkid", v.(string)) - } - return u -} - -func (p *ReplaceNetworkACLListParams) SetAclid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["aclid"] = v - return -} - -func (p *ReplaceNetworkACLListParams) SetGatewayid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["gatewayid"] = v - return -} - -func (p *ReplaceNetworkACLListParams) SetNetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkid"] = v - return -} - -// You should always use this function to get a new ReplaceNetworkACLListParams instance, -// as then you are sure you have configured all required params -func (s *NetworkACLService) NewReplaceNetworkACLListParams(aclid string) *ReplaceNetworkACLListParams { - p := &ReplaceNetworkACLListParams{} - p.p = make(map[string]interface{}) - p.p["aclid"] = aclid - return p -} - -// Replaces ACL associated with a network or private gateway -func (s *NetworkACLService) ReplaceNetworkACLList(p *ReplaceNetworkACLListParams) (*ReplaceNetworkACLListResponse, error) { - resp, err := s.cs.newRequest("replaceNetworkACLList", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ReplaceNetworkACLListResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type ReplaceNetworkACLListResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListNetworkACLListsParams struct { - p map[string]interface{} -} - -func (p *ListNetworkACLListsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["networkid"]; found { - u.Set("networkid", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["vpcid"]; found { - u.Set("vpcid", v.(string)) - } - return u -} - -func (p *ListNetworkACLListsParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListNetworkACLListsParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListNetworkACLListsParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *ListNetworkACLListsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListNetworkACLListsParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListNetworkACLListsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListNetworkACLListsParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListNetworkACLListsParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListNetworkACLListsParams) SetNetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkid"] = v - return -} - -func (p *ListNetworkACLListsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListNetworkACLListsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListNetworkACLListsParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListNetworkACLListsParams) SetVpcid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vpcid"] = v - return -} - -// You should always use this function to get a new ListNetworkACLListsParams instance, -// as then you are sure you have configured all required params -func (s *NetworkACLService) NewListNetworkACLListsParams() *ListNetworkACLListsParams { - p := &ListNetworkACLListsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *NetworkACLService) GetNetworkACLListID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListNetworkACLListsParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListNetworkACLLists(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.NetworkACLLists[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.NetworkACLLists { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *NetworkACLService) GetNetworkACLListByName(name string, opts ...OptionFunc) (*NetworkACLList, int, error) { - id, count, err := s.GetNetworkACLListID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetNetworkACLListByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *NetworkACLService) GetNetworkACLListByID(id string, opts ...OptionFunc) (*NetworkACLList, int, error) { - p := &ListNetworkACLListsParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListNetworkACLLists(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.NetworkACLLists[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for NetworkACLList UUID: %s!", id) -} - -// Lists all network ACLs -func (s *NetworkACLService) ListNetworkACLLists(p *ListNetworkACLListsParams) (*ListNetworkACLListsResponse, error) { - resp, err := s.cs.newRequest("listNetworkACLLists", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListNetworkACLListsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListNetworkACLListsResponse struct { - Count int `json:"count"` - NetworkACLLists []*NetworkACLList `json:"networkacllist"` -} - -type NetworkACLList struct { - Description string `json:"description,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Vpcid string `json:"vpcid,omitempty"` -} - -type UpdateNetworkACLListParams struct { - p map[string]interface{} -} - -func (p *UpdateNetworkACLListParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["customid"]; found { - u.Set("customid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *UpdateNetworkACLListParams) SetCustomid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["customid"] = v - return -} - -func (p *UpdateNetworkACLListParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *UpdateNetworkACLListParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new UpdateNetworkACLListParams instance, -// as then you are sure you have configured all required params -func (s *NetworkACLService) NewUpdateNetworkACLListParams(id string) *UpdateNetworkACLListParams { - p := &UpdateNetworkACLListParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates network ACL list -func (s *NetworkACLService) UpdateNetworkACLList(p *UpdateNetworkACLListParams) (*UpdateNetworkACLListResponse, error) { - resp, err := s.cs.newRequest("updateNetworkACLList", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateNetworkACLListResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateNetworkACLListResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/NetworkDeviceService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/NetworkDeviceService.go deleted file mode 100644 index 878d5286ef5..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/NetworkDeviceService.go +++ /dev/null @@ -1,245 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" -) - -type AddNetworkDeviceParams struct { - p map[string]interface{} -} - -func (p *AddNetworkDeviceParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["networkdeviceparameterlist"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("networkdeviceparameterlist[%d].key", i), k) - u.Set(fmt.Sprintf("networkdeviceparameterlist[%d].value", i), vv) - i++ - } - } - if v, found := p.p["networkdevicetype"]; found { - u.Set("networkdevicetype", v.(string)) - } - return u -} - -func (p *AddNetworkDeviceParams) SetNetworkdeviceparameterlist(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkdeviceparameterlist"] = v - return -} - -func (p *AddNetworkDeviceParams) SetNetworkdevicetype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkdevicetype"] = v - return -} - -// You should always use this function to get a new AddNetworkDeviceParams instance, -// as then you are sure you have configured all required params -func (s *NetworkDeviceService) NewAddNetworkDeviceParams() *AddNetworkDeviceParams { - p := &AddNetworkDeviceParams{} - p.p = make(map[string]interface{}) - return p -} - -// Adds a network device of one of the following types: ExternalDhcp, ExternalFirewall, ExternalLoadBalancer, PxeServer -func (s *NetworkDeviceService) AddNetworkDevice(p *AddNetworkDeviceParams) (*AddNetworkDeviceResponse, error) { - resp, err := s.cs.newRequest("addNetworkDevice", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AddNetworkDeviceResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type AddNetworkDeviceResponse struct { - Id string `json:"id,omitempty"` -} - -type ListNetworkDeviceParams struct { - p map[string]interface{} -} - -func (p *ListNetworkDeviceParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["networkdeviceparameterlist"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("networkdeviceparameterlist[%d].key", i), k) - u.Set(fmt.Sprintf("networkdeviceparameterlist[%d].value", i), vv) - i++ - } - } - if v, found := p.p["networkdevicetype"]; found { - u.Set("networkdevicetype", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - return u -} - -func (p *ListNetworkDeviceParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListNetworkDeviceParams) SetNetworkdeviceparameterlist(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkdeviceparameterlist"] = v - return -} - -func (p *ListNetworkDeviceParams) SetNetworkdevicetype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkdevicetype"] = v - return -} - -func (p *ListNetworkDeviceParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListNetworkDeviceParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -// You should always use this function to get a new ListNetworkDeviceParams instance, -// as then you are sure you have configured all required params -func (s *NetworkDeviceService) NewListNetworkDeviceParams() *ListNetworkDeviceParams { - p := &ListNetworkDeviceParams{} - p.p = make(map[string]interface{}) - return p -} - -// List network devices -func (s *NetworkDeviceService) ListNetworkDevice(p *ListNetworkDeviceParams) (*ListNetworkDeviceResponse, error) { - resp, err := s.cs.newRequest("listNetworkDevice", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListNetworkDeviceResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListNetworkDeviceResponse struct { - Count int `json:"count"` - NetworkDevice []*NetworkDevice `json:"networkdevice"` -} - -type NetworkDevice struct { - Id string `json:"id,omitempty"` -} - -type DeleteNetworkDeviceParams struct { - p map[string]interface{} -} - -func (p *DeleteNetworkDeviceParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteNetworkDeviceParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteNetworkDeviceParams instance, -// as then you are sure you have configured all required params -func (s *NetworkDeviceService) NewDeleteNetworkDeviceParams(id string) *DeleteNetworkDeviceParams { - p := &DeleteNetworkDeviceParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes network device. -func (s *NetworkDeviceService) DeleteNetworkDevice(p *DeleteNetworkDeviceParams) (*DeleteNetworkDeviceResponse, error) { - resp, err := s.cs.newRequest("deleteNetworkDevice", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteNetworkDeviceResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type DeleteNetworkDeviceResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/NetworkOfferingService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/NetworkOfferingService.go deleted file mode 100644 index e0adf29afa6..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/NetworkOfferingService.go +++ /dev/null @@ -1,951 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type CreateNetworkOfferingParams struct { - p map[string]interface{} -} - -func (p *CreateNetworkOfferingParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["availability"]; found { - u.Set("availability", v.(string)) - } - if v, found := p.p["conservemode"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("conservemode", vv) - } - if v, found := p.p["details"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("details[%d].key", i), k) - u.Set(fmt.Sprintf("details[%d].value", i), vv) - i++ - } - } - if v, found := p.p["displaytext"]; found { - u.Set("displaytext", v.(string)) - } - if v, found := p.p["egressdefaultpolicy"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("egressdefaultpolicy", vv) - } - if v, found := p.p["guestiptype"]; found { - u.Set("guestiptype", v.(string)) - } - if v, found := p.p["ispersistent"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("ispersistent", vv) - } - if v, found := p.p["keepaliveenabled"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("keepaliveenabled", vv) - } - if v, found := p.p["maxconnections"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("maxconnections", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["networkrate"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("networkrate", vv) - } - if v, found := p.p["servicecapabilitylist"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("servicecapabilitylist[%d].key", i), k) - u.Set(fmt.Sprintf("servicecapabilitylist[%d].value", i), vv) - i++ - } - } - if v, found := p.p["serviceofferingid"]; found { - u.Set("serviceofferingid", v.(string)) - } - if v, found := p.p["serviceproviderlist"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("serviceproviderlist[%d].service", i), k) - u.Set(fmt.Sprintf("serviceproviderlist[%d].provider", i), vv) - i++ - } - } - if v, found := p.p["specifyipranges"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("specifyipranges", vv) - } - if v, found := p.p["specifyvlan"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("specifyvlan", vv) - } - if v, found := p.p["supportedservices"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("supportedservices", vv) - } - if v, found := p.p["tags"]; found { - u.Set("tags", v.(string)) - } - if v, found := p.p["traffictype"]; found { - u.Set("traffictype", v.(string)) - } - return u -} - -func (p *CreateNetworkOfferingParams) SetAvailability(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["availability"] = v - return -} - -func (p *CreateNetworkOfferingParams) SetConservemode(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["conservemode"] = v - return -} - -func (p *CreateNetworkOfferingParams) SetDetails(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["details"] = v - return -} - -func (p *CreateNetworkOfferingParams) SetDisplaytext(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displaytext"] = v - return -} - -func (p *CreateNetworkOfferingParams) SetEgressdefaultpolicy(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["egressdefaultpolicy"] = v - return -} - -func (p *CreateNetworkOfferingParams) SetGuestiptype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["guestiptype"] = v - return -} - -func (p *CreateNetworkOfferingParams) SetIspersistent(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ispersistent"] = v - return -} - -func (p *CreateNetworkOfferingParams) SetKeepaliveenabled(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keepaliveenabled"] = v - return -} - -func (p *CreateNetworkOfferingParams) SetMaxconnections(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["maxconnections"] = v - return -} - -func (p *CreateNetworkOfferingParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *CreateNetworkOfferingParams) SetNetworkrate(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkrate"] = v - return -} - -func (p *CreateNetworkOfferingParams) SetServicecapabilitylist(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["servicecapabilitylist"] = v - return -} - -func (p *CreateNetworkOfferingParams) SetServiceofferingid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["serviceofferingid"] = v - return -} - -func (p *CreateNetworkOfferingParams) SetServiceproviderlist(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["serviceproviderlist"] = v - return -} - -func (p *CreateNetworkOfferingParams) SetSpecifyipranges(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["specifyipranges"] = v - return -} - -func (p *CreateNetworkOfferingParams) SetSpecifyvlan(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["specifyvlan"] = v - return -} - -func (p *CreateNetworkOfferingParams) SetSupportedservices(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["supportedservices"] = v - return -} - -func (p *CreateNetworkOfferingParams) SetTags(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tags"] = v - return -} - -func (p *CreateNetworkOfferingParams) SetTraffictype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["traffictype"] = v - return -} - -// You should always use this function to get a new CreateNetworkOfferingParams instance, -// as then you are sure you have configured all required params -func (s *NetworkOfferingService) NewCreateNetworkOfferingParams(displaytext string, guestiptype string, name string, supportedservices []string, traffictype string) *CreateNetworkOfferingParams { - p := &CreateNetworkOfferingParams{} - p.p = make(map[string]interface{}) - p.p["displaytext"] = displaytext - p.p["guestiptype"] = guestiptype - p.p["name"] = name - p.p["supportedservices"] = supportedservices - p.p["traffictype"] = traffictype - return p -} - -// Creates a network offering. -func (s *NetworkOfferingService) CreateNetworkOffering(p *CreateNetworkOfferingParams) (*CreateNetworkOfferingResponse, error) { - resp, err := s.cs.newRequest("createNetworkOffering", p.toURLValues()) - if err != nil { - return nil, err - } - - if resp, err = getRawValue(resp); err != nil { - return nil, err - } - - var r CreateNetworkOfferingResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type CreateNetworkOfferingResponse struct { - Availability string `json:"availability,omitempty"` - Conservemode bool `json:"conservemode,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Egressdefaultpolicy bool `json:"egressdefaultpolicy,omitempty"` - Forvpc bool `json:"forvpc,omitempty"` - Guestiptype string `json:"guestiptype,omitempty"` - Id string `json:"id,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Ispersistent bool `json:"ispersistent,omitempty"` - Maxconnections int `json:"maxconnections,omitempty"` - Name string `json:"name,omitempty"` - Networkrate int `json:"networkrate,omitempty"` - Service []struct { - Capability []struct { - Canchooseservicecapability bool `json:"canchooseservicecapability,omitempty"` - Name string `json:"name,omitempty"` - Value string `json:"value,omitempty"` - } `json:"capability,omitempty"` - Name string `json:"name,omitempty"` - Provider []struct { - Canenableindividualservice bool `json:"canenableindividualservice,omitempty"` - Destinationphysicalnetworkid string `json:"destinationphysicalnetworkid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Servicelist []string `json:"servicelist,omitempty"` - State string `json:"state,omitempty"` - } `json:"provider,omitempty"` - } `json:"service,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Specifyipranges bool `json:"specifyipranges,omitempty"` - Specifyvlan bool `json:"specifyvlan,omitempty"` - State string `json:"state,omitempty"` - Supportsstrechedl2subnet bool `json:"supportsstrechedl2subnet,omitempty"` - Tags string `json:"tags,omitempty"` - Traffictype string `json:"traffictype,omitempty"` -} - -type UpdateNetworkOfferingParams struct { - p map[string]interface{} -} - -func (p *UpdateNetworkOfferingParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["availability"]; found { - u.Set("availability", v.(string)) - } - if v, found := p.p["displaytext"]; found { - u.Set("displaytext", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["keepaliveenabled"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("keepaliveenabled", vv) - } - if v, found := p.p["maxconnections"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("maxconnections", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["sortkey"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("sortkey", vv) - } - if v, found := p.p["state"]; found { - u.Set("state", v.(string)) - } - return u -} - -func (p *UpdateNetworkOfferingParams) SetAvailability(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["availability"] = v - return -} - -func (p *UpdateNetworkOfferingParams) SetDisplaytext(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displaytext"] = v - return -} - -func (p *UpdateNetworkOfferingParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateNetworkOfferingParams) SetKeepaliveenabled(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keepaliveenabled"] = v - return -} - -func (p *UpdateNetworkOfferingParams) SetMaxconnections(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["maxconnections"] = v - return -} - -func (p *UpdateNetworkOfferingParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *UpdateNetworkOfferingParams) SetSortkey(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["sortkey"] = v - return -} - -func (p *UpdateNetworkOfferingParams) SetState(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["state"] = v - return -} - -// You should always use this function to get a new UpdateNetworkOfferingParams instance, -// as then you are sure you have configured all required params -func (s *NetworkOfferingService) NewUpdateNetworkOfferingParams() *UpdateNetworkOfferingParams { - p := &UpdateNetworkOfferingParams{} - p.p = make(map[string]interface{}) - return p -} - -// Updates a network offering. -func (s *NetworkOfferingService) UpdateNetworkOffering(p *UpdateNetworkOfferingParams) (*UpdateNetworkOfferingResponse, error) { - resp, err := s.cs.newRequest("updateNetworkOffering", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateNetworkOfferingResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type UpdateNetworkOfferingResponse struct { - Availability string `json:"availability,omitempty"` - Conservemode bool `json:"conservemode,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Egressdefaultpolicy bool `json:"egressdefaultpolicy,omitempty"` - Forvpc bool `json:"forvpc,omitempty"` - Guestiptype string `json:"guestiptype,omitempty"` - Id string `json:"id,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Ispersistent bool `json:"ispersistent,omitempty"` - Maxconnections int `json:"maxconnections,omitempty"` - Name string `json:"name,omitempty"` - Networkrate int `json:"networkrate,omitempty"` - Service []struct { - Capability []struct { - Canchooseservicecapability bool `json:"canchooseservicecapability,omitempty"` - Name string `json:"name,omitempty"` - Value string `json:"value,omitempty"` - } `json:"capability,omitempty"` - Name string `json:"name,omitempty"` - Provider []struct { - Canenableindividualservice bool `json:"canenableindividualservice,omitempty"` - Destinationphysicalnetworkid string `json:"destinationphysicalnetworkid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Servicelist []string `json:"servicelist,omitempty"` - State string `json:"state,omitempty"` - } `json:"provider,omitempty"` - } `json:"service,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Specifyipranges bool `json:"specifyipranges,omitempty"` - Specifyvlan bool `json:"specifyvlan,omitempty"` - State string `json:"state,omitempty"` - Supportsstrechedl2subnet bool `json:"supportsstrechedl2subnet,omitempty"` - Tags string `json:"tags,omitempty"` - Traffictype string `json:"traffictype,omitempty"` -} - -type DeleteNetworkOfferingParams struct { - p map[string]interface{} -} - -func (p *DeleteNetworkOfferingParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteNetworkOfferingParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteNetworkOfferingParams instance, -// as then you are sure you have configured all required params -func (s *NetworkOfferingService) NewDeleteNetworkOfferingParams(id string) *DeleteNetworkOfferingParams { - p := &DeleteNetworkOfferingParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a network offering. -func (s *NetworkOfferingService) DeleteNetworkOffering(p *DeleteNetworkOfferingParams) (*DeleteNetworkOfferingResponse, error) { - resp, err := s.cs.newRequest("deleteNetworkOffering", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteNetworkOfferingResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type DeleteNetworkOfferingResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} - -type ListNetworkOfferingsParams struct { - p map[string]interface{} -} - -func (p *ListNetworkOfferingsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["availability"]; found { - u.Set("availability", v.(string)) - } - if v, found := p.p["displaytext"]; found { - u.Set("displaytext", v.(string)) - } - if v, found := p.p["forvpc"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("forvpc", vv) - } - if v, found := p.p["guestiptype"]; found { - u.Set("guestiptype", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isdefault"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isdefault", vv) - } - if v, found := p.p["istagged"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("istagged", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["networkid"]; found { - u.Set("networkid", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["sourcenatsupported"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("sourcenatsupported", vv) - } - if v, found := p.p["specifyipranges"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("specifyipranges", vv) - } - if v, found := p.p["specifyvlan"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("specifyvlan", vv) - } - if v, found := p.p["state"]; found { - u.Set("state", v.(string)) - } - if v, found := p.p["supportedservices"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("supportedservices", vv) - } - if v, found := p.p["tags"]; found { - u.Set("tags", v.(string)) - } - if v, found := p.p["traffictype"]; found { - u.Set("traffictype", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ListNetworkOfferingsParams) SetAvailability(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["availability"] = v - return -} - -func (p *ListNetworkOfferingsParams) SetDisplaytext(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displaytext"] = v - return -} - -func (p *ListNetworkOfferingsParams) SetForvpc(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["forvpc"] = v - return -} - -func (p *ListNetworkOfferingsParams) SetGuestiptype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["guestiptype"] = v - return -} - -func (p *ListNetworkOfferingsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListNetworkOfferingsParams) SetIsdefault(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isdefault"] = v - return -} - -func (p *ListNetworkOfferingsParams) SetIstagged(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["istagged"] = v - return -} - -func (p *ListNetworkOfferingsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListNetworkOfferingsParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListNetworkOfferingsParams) SetNetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkid"] = v - return -} - -func (p *ListNetworkOfferingsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListNetworkOfferingsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListNetworkOfferingsParams) SetSourcenatsupported(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["sourcenatsupported"] = v - return -} - -func (p *ListNetworkOfferingsParams) SetSpecifyipranges(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["specifyipranges"] = v - return -} - -func (p *ListNetworkOfferingsParams) SetSpecifyvlan(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["specifyvlan"] = v - return -} - -func (p *ListNetworkOfferingsParams) SetState(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["state"] = v - return -} - -func (p *ListNetworkOfferingsParams) SetSupportedservices(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["supportedservices"] = v - return -} - -func (p *ListNetworkOfferingsParams) SetTags(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tags"] = v - return -} - -func (p *ListNetworkOfferingsParams) SetTraffictype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["traffictype"] = v - return -} - -func (p *ListNetworkOfferingsParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ListNetworkOfferingsParams instance, -// as then you are sure you have configured all required params -func (s *NetworkOfferingService) NewListNetworkOfferingsParams() *ListNetworkOfferingsParams { - p := &ListNetworkOfferingsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *NetworkOfferingService) GetNetworkOfferingID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListNetworkOfferingsParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListNetworkOfferings(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.NetworkOfferings[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.NetworkOfferings { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *NetworkOfferingService) GetNetworkOfferingByName(name string, opts ...OptionFunc) (*NetworkOffering, int, error) { - id, count, err := s.GetNetworkOfferingID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetNetworkOfferingByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *NetworkOfferingService) GetNetworkOfferingByID(id string, opts ...OptionFunc) (*NetworkOffering, int, error) { - p := &ListNetworkOfferingsParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListNetworkOfferings(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.NetworkOfferings[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for NetworkOffering UUID: %s!", id) -} - -// Lists all available network offerings. -func (s *NetworkOfferingService) ListNetworkOfferings(p *ListNetworkOfferingsParams) (*ListNetworkOfferingsResponse, error) { - resp, err := s.cs.newRequest("listNetworkOfferings", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListNetworkOfferingsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListNetworkOfferingsResponse struct { - Count int `json:"count"` - NetworkOfferings []*NetworkOffering `json:"networkoffering"` -} - -type NetworkOffering struct { - Availability string `json:"availability,omitempty"` - Conservemode bool `json:"conservemode,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Egressdefaultpolicy bool `json:"egressdefaultpolicy,omitempty"` - Forvpc bool `json:"forvpc,omitempty"` - Guestiptype string `json:"guestiptype,omitempty"` - Id string `json:"id,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Ispersistent bool `json:"ispersistent,omitempty"` - Maxconnections int `json:"maxconnections,omitempty"` - Name string `json:"name,omitempty"` - Networkrate int `json:"networkrate,omitempty"` - Service []struct { - Capability []struct { - Canchooseservicecapability bool `json:"canchooseservicecapability,omitempty"` - Name string `json:"name,omitempty"` - Value string `json:"value,omitempty"` - } `json:"capability,omitempty"` - Name string `json:"name,omitempty"` - Provider []struct { - Canenableindividualservice bool `json:"canenableindividualservice,omitempty"` - Destinationphysicalnetworkid string `json:"destinationphysicalnetworkid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Servicelist []string `json:"servicelist,omitempty"` - State string `json:"state,omitempty"` - } `json:"provider,omitempty"` - } `json:"service,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Specifyipranges bool `json:"specifyipranges,omitempty"` - Specifyvlan bool `json:"specifyvlan,omitempty"` - State string `json:"state,omitempty"` - Supportsstrechedl2subnet bool `json:"supportsstrechedl2subnet,omitempty"` - Tags string `json:"tags,omitempty"` - Traffictype string `json:"traffictype,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/NetworkService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/NetworkService.go deleted file mode 100644 index ac4944c9213..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/NetworkService.go +++ /dev/null @@ -1,4024 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type DedicatePublicIpRangeParams struct { - p map[string]interface{} -} - -func (p *DedicatePublicIpRangeParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - return u -} - -func (p *DedicatePublicIpRangeParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *DedicatePublicIpRangeParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *DedicatePublicIpRangeParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *DedicatePublicIpRangeParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -// You should always use this function to get a new DedicatePublicIpRangeParams instance, -// as then you are sure you have configured all required params -func (s *NetworkService) NewDedicatePublicIpRangeParams(domainid string, id string) *DedicatePublicIpRangeParams { - p := &DedicatePublicIpRangeParams{} - p.p = make(map[string]interface{}) - p.p["domainid"] = domainid - p.p["id"] = id - return p -} - -// Dedicates a Public IP range to an account -func (s *NetworkService) DedicatePublicIpRange(p *DedicatePublicIpRangeParams) (*DedicatePublicIpRangeResponse, error) { - resp, err := s.cs.newRequest("dedicatePublicIpRange", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DedicatePublicIpRangeResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type DedicatePublicIpRangeResponse struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Endip string `json:"endip,omitempty"` - Endipv6 string `json:"endipv6,omitempty"` - Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Startip string `json:"startip,omitempty"` - Startipv6 string `json:"startipv6,omitempty"` - Vlan string `json:"vlan,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type ReleasePublicIpRangeParams struct { - p map[string]interface{} -} - -func (p *ReleasePublicIpRangeParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *ReleasePublicIpRangeParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new ReleasePublicIpRangeParams instance, -// as then you are sure you have configured all required params -func (s *NetworkService) NewReleasePublicIpRangeParams(id string) *ReleasePublicIpRangeParams { - p := &ReleasePublicIpRangeParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Releases a Public IP range back to the system pool -func (s *NetworkService) ReleasePublicIpRange(p *ReleasePublicIpRangeParams) (*ReleasePublicIpRangeResponse, error) { - resp, err := s.cs.newRequest("releasePublicIpRange", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ReleasePublicIpRangeResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ReleasePublicIpRangeResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} - -type CreateNetworkParams struct { - p map[string]interface{} -} - -func (p *CreateNetworkParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["aclid"]; found { - u.Set("aclid", v.(string)) - } - if v, found := p.p["acltype"]; found { - u.Set("acltype", v.(string)) - } - if v, found := p.p["displaynetwork"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("displaynetwork", vv) - } - if v, found := p.p["displaytext"]; found { - u.Set("displaytext", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["endip"]; found { - u.Set("endip", v.(string)) - } - if v, found := p.p["endipv6"]; found { - u.Set("endipv6", v.(string)) - } - if v, found := p.p["gateway"]; found { - u.Set("gateway", v.(string)) - } - if v, found := p.p["ip6cidr"]; found { - u.Set("ip6cidr", v.(string)) - } - if v, found := p.p["ip6gateway"]; found { - u.Set("ip6gateway", v.(string)) - } - if v, found := p.p["isolatedpvlan"]; found { - u.Set("isolatedpvlan", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["netmask"]; found { - u.Set("netmask", v.(string)) - } - if v, found := p.p["networkdomain"]; found { - u.Set("networkdomain", v.(string)) - } - if v, found := p.p["networkofferingid"]; found { - u.Set("networkofferingid", v.(string)) - } - if v, found := p.p["physicalnetworkid"]; found { - u.Set("physicalnetworkid", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["startip"]; found { - u.Set("startip", v.(string)) - } - if v, found := p.p["startipv6"]; found { - u.Set("startipv6", v.(string)) - } - if v, found := p.p["subdomainaccess"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("subdomainaccess", vv) - } - if v, found := p.p["vlan"]; found { - u.Set("vlan", v.(string)) - } - if v, found := p.p["vpcid"]; found { - u.Set("vpcid", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *CreateNetworkParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *CreateNetworkParams) SetAclid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["aclid"] = v - return -} - -func (p *CreateNetworkParams) SetAcltype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["acltype"] = v - return -} - -func (p *CreateNetworkParams) SetDisplaynetwork(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displaynetwork"] = v - return -} - -func (p *CreateNetworkParams) SetDisplaytext(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displaytext"] = v - return -} - -func (p *CreateNetworkParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *CreateNetworkParams) SetEndip(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["endip"] = v - return -} - -func (p *CreateNetworkParams) SetEndipv6(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["endipv6"] = v - return -} - -func (p *CreateNetworkParams) SetGateway(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["gateway"] = v - return -} - -func (p *CreateNetworkParams) SetIp6cidr(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ip6cidr"] = v - return -} - -func (p *CreateNetworkParams) SetIp6gateway(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ip6gateway"] = v - return -} - -func (p *CreateNetworkParams) SetIsolatedpvlan(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isolatedpvlan"] = v - return -} - -func (p *CreateNetworkParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *CreateNetworkParams) SetNetmask(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["netmask"] = v - return -} - -func (p *CreateNetworkParams) SetNetworkdomain(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkdomain"] = v - return -} - -func (p *CreateNetworkParams) SetNetworkofferingid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkofferingid"] = v - return -} - -func (p *CreateNetworkParams) SetPhysicalnetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["physicalnetworkid"] = v - return -} - -func (p *CreateNetworkParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *CreateNetworkParams) SetStartip(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["startip"] = v - return -} - -func (p *CreateNetworkParams) SetStartipv6(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["startipv6"] = v - return -} - -func (p *CreateNetworkParams) SetSubdomainaccess(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["subdomainaccess"] = v - return -} - -func (p *CreateNetworkParams) SetVlan(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vlan"] = v - return -} - -func (p *CreateNetworkParams) SetVpcid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vpcid"] = v - return -} - -func (p *CreateNetworkParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new CreateNetworkParams instance, -// as then you are sure you have configured all required params -func (s *NetworkService) NewCreateNetworkParams(displaytext string, name string, networkofferingid string, zoneid string) *CreateNetworkParams { - p := &CreateNetworkParams{} - p.p = make(map[string]interface{}) - p.p["displaytext"] = displaytext - p.p["name"] = name - p.p["networkofferingid"] = networkofferingid - p.p["zoneid"] = zoneid - return p -} - -// Creates a network -func (s *NetworkService) CreateNetwork(p *CreateNetworkParams) (*CreateNetworkResponse, error) { - resp, err := s.cs.newRequest("createNetwork", p.toURLValues()) - if err != nil { - return nil, err - } - - if resp, err = getRawValue(resp); err != nil { - return nil, err - } - - var r CreateNetworkResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type CreateNetworkResponse struct { - Account string `json:"account,omitempty"` - Aclid string `json:"aclid,omitempty"` - Acltype string `json:"acltype,omitempty"` - Broadcastdomaintype string `json:"broadcastdomaintype,omitempty"` - Broadcasturi string `json:"broadcasturi,omitempty"` - Canusefordeploy bool `json:"canusefordeploy,omitempty"` - Cidr string `json:"cidr,omitempty"` - Displaynetwork bool `json:"displaynetwork,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Dns1 string `json:"dns1,omitempty"` - Dns2 string `json:"dns2,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Ispersistent bool `json:"ispersistent,omitempty"` - Issystem bool `json:"issystem,omitempty"` - Name string `json:"name,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkcidr string `json:"networkcidr,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Networkofferingavailability string `json:"networkofferingavailability,omitempty"` - Networkofferingconservemode bool `json:"networkofferingconservemode,omitempty"` - Networkofferingdisplaytext string `json:"networkofferingdisplaytext,omitempty"` - Networkofferingid string `json:"networkofferingid,omitempty"` - Networkofferingname string `json:"networkofferingname,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Related string `json:"related,omitempty"` - Reservediprange string `json:"reservediprange,omitempty"` - Restartrequired bool `json:"restartrequired,omitempty"` - Service []struct { - Capability []struct { - Canchooseservicecapability bool `json:"canchooseservicecapability,omitempty"` - Name string `json:"name,omitempty"` - Value string `json:"value,omitempty"` - } `json:"capability,omitempty"` - Name string `json:"name,omitempty"` - Provider []struct { - Canenableindividualservice bool `json:"canenableindividualservice,omitempty"` - Destinationphysicalnetworkid string `json:"destinationphysicalnetworkid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Servicelist []string `json:"servicelist,omitempty"` - State string `json:"state,omitempty"` - } `json:"provider,omitempty"` - } `json:"service,omitempty"` - Specifyipranges bool `json:"specifyipranges,omitempty"` - State string `json:"state,omitempty"` - Strechedl2subnet bool `json:"strechedl2subnet,omitempty"` - Subdomainaccess bool `json:"subdomainaccess,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Vlan string `json:"vlan,omitempty"` - Vpcid string `json:"vpcid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` - Zonesnetworkspans []string `json:"zonesnetworkspans,omitempty"` -} - -type DeleteNetworkParams struct { - p map[string]interface{} -} - -func (p *DeleteNetworkParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["forced"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("forced", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteNetworkParams) SetForced(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["forced"] = v - return -} - -func (p *DeleteNetworkParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteNetworkParams instance, -// as then you are sure you have configured all required params -func (s *NetworkService) NewDeleteNetworkParams(id string) *DeleteNetworkParams { - p := &DeleteNetworkParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a network -func (s *NetworkService) DeleteNetwork(p *DeleteNetworkParams) (*DeleteNetworkResponse, error) { - resp, err := s.cs.newRequest("deleteNetwork", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteNetworkResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteNetworkResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListNetworksParams struct { - p map[string]interface{} -} - -func (p *ListNetworksParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["acltype"]; found { - u.Set("acltype", v.(string)) - } - if v, found := p.p["canusefordeploy"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("canusefordeploy", vv) - } - if v, found := p.p["displaynetwork"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("displaynetwork", vv) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["forvpc"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("forvpc", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["issystem"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("issystem", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["physicalnetworkid"]; found { - u.Set("physicalnetworkid", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["restartrequired"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("restartrequired", vv) - } - if v, found := p.p["specifyipranges"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("specifyipranges", vv) - } - if v, found := p.p["supportedservices"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("supportedservices", vv) - } - if v, found := p.p["tags"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("tags[%d].key", i), k) - u.Set(fmt.Sprintf("tags[%d].value", i), vv) - i++ - } - } - if v, found := p.p["traffictype"]; found { - u.Set("traffictype", v.(string)) - } - if v, found := p.p["type"]; found { - u.Set("type", v.(string)) - } - if v, found := p.p["vpcid"]; found { - u.Set("vpcid", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ListNetworksParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListNetworksParams) SetAcltype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["acltype"] = v - return -} - -func (p *ListNetworksParams) SetCanusefordeploy(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["canusefordeploy"] = v - return -} - -func (p *ListNetworksParams) SetDisplaynetwork(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displaynetwork"] = v - return -} - -func (p *ListNetworksParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListNetworksParams) SetForvpc(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["forvpc"] = v - return -} - -func (p *ListNetworksParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListNetworksParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListNetworksParams) SetIssystem(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["issystem"] = v - return -} - -func (p *ListNetworksParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListNetworksParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListNetworksParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListNetworksParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListNetworksParams) SetPhysicalnetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["physicalnetworkid"] = v - return -} - -func (p *ListNetworksParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListNetworksParams) SetRestartrequired(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["restartrequired"] = v - return -} - -func (p *ListNetworksParams) SetSpecifyipranges(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["specifyipranges"] = v - return -} - -func (p *ListNetworksParams) SetSupportedservices(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["supportedservices"] = v - return -} - -func (p *ListNetworksParams) SetTags(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tags"] = v - return -} - -func (p *ListNetworksParams) SetTraffictype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["traffictype"] = v - return -} - -func (p *ListNetworksParams) SetType(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkType"] = v - return -} - -func (p *ListNetworksParams) SetVpcid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vpcid"] = v - return -} - -func (p *ListNetworksParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ListNetworksParams instance, -// as then you are sure you have configured all required params -func (s *NetworkService) NewListNetworksParams() *ListNetworksParams { - p := &ListNetworksParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *NetworkService) GetNetworkID(keyword string, opts ...OptionFunc) (string, int, error) { - p := &ListNetworksParams{} - p.p = make(map[string]interface{}) - - p.p["keyword"] = keyword - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListNetworks(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", keyword, l) - } - - if l.Count == 1 { - return l.Networks[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.Networks { - if v.Name == keyword { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *NetworkService) GetNetworkByName(name string, opts ...OptionFunc) (*Network, int, error) { - id, count, err := s.GetNetworkID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetNetworkByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *NetworkService) GetNetworkByID(id string, opts ...OptionFunc) (*Network, int, error) { - p := &ListNetworksParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListNetworks(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.Networks[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for Network UUID: %s!", id) -} - -// Lists all available networks. -func (s *NetworkService) ListNetworks(p *ListNetworksParams) (*ListNetworksResponse, error) { - resp, err := s.cs.newRequest("listNetworks", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListNetworksResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListNetworksResponse struct { - Count int `json:"count"` - Networks []*Network `json:"network"` -} - -type Network struct { - Account string `json:"account,omitempty"` - Aclid string `json:"aclid,omitempty"` - Acltype string `json:"acltype,omitempty"` - Broadcastdomaintype string `json:"broadcastdomaintype,omitempty"` - Broadcasturi string `json:"broadcasturi,omitempty"` - Canusefordeploy bool `json:"canusefordeploy,omitempty"` - Cidr string `json:"cidr,omitempty"` - Displaynetwork bool `json:"displaynetwork,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Dns1 string `json:"dns1,omitempty"` - Dns2 string `json:"dns2,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Ispersistent bool `json:"ispersistent,omitempty"` - Issystem bool `json:"issystem,omitempty"` - Name string `json:"name,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkcidr string `json:"networkcidr,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Networkofferingavailability string `json:"networkofferingavailability,omitempty"` - Networkofferingconservemode bool `json:"networkofferingconservemode,omitempty"` - Networkofferingdisplaytext string `json:"networkofferingdisplaytext,omitempty"` - Networkofferingid string `json:"networkofferingid,omitempty"` - Networkofferingname string `json:"networkofferingname,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Related string `json:"related,omitempty"` - Reservediprange string `json:"reservediprange,omitempty"` - Restartrequired bool `json:"restartrequired,omitempty"` - Service []struct { - Capability []struct { - Canchooseservicecapability bool `json:"canchooseservicecapability,omitempty"` - Name string `json:"name,omitempty"` - Value string `json:"value,omitempty"` - } `json:"capability,omitempty"` - Name string `json:"name,omitempty"` - Provider []struct { - Canenableindividualservice bool `json:"canenableindividualservice,omitempty"` - Destinationphysicalnetworkid string `json:"destinationphysicalnetworkid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Servicelist []string `json:"servicelist,omitempty"` - State string `json:"state,omitempty"` - } `json:"provider,omitempty"` - } `json:"service,omitempty"` - Specifyipranges bool `json:"specifyipranges,omitempty"` - State string `json:"state,omitempty"` - Strechedl2subnet bool `json:"strechedl2subnet,omitempty"` - Subdomainaccess bool `json:"subdomainaccess,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Vlan string `json:"vlan,omitempty"` - Vpcid string `json:"vpcid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` - Zonesnetworkspans []string `json:"zonesnetworkspans,omitempty"` -} - -type RestartNetworkParams struct { - p map[string]interface{} -} - -func (p *RestartNetworkParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["cleanup"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("cleanup", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *RestartNetworkParams) SetCleanup(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["cleanup"] = v - return -} - -func (p *RestartNetworkParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new RestartNetworkParams instance, -// as then you are sure you have configured all required params -func (s *NetworkService) NewRestartNetworkParams(id string) *RestartNetworkParams { - p := &RestartNetworkParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Restarts the network; includes 1) restarting network elements - virtual routers, DHCP servers 2) reapplying all public IPs 3) reapplying loadBalancing/portForwarding rules -func (s *NetworkService) RestartNetwork(p *RestartNetworkParams) (*RestartNetworkResponse, error) { - resp, err := s.cs.newRequest("restartNetwork", p.toURLValues()) - if err != nil { - return nil, err - } - - var r RestartNetworkResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type RestartNetworkResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Allocated string `json:"allocated,omitempty"` - Associatednetworkid string `json:"associatednetworkid,omitempty"` - Associatednetworkname string `json:"associatednetworkname,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isportable bool `json:"isportable,omitempty"` - Issourcenat bool `json:"issourcenat,omitempty"` - Isstaticnat bool `json:"isstaticnat,omitempty"` - Issystem bool `json:"issystem,omitempty"` - Networkid string `json:"networkid,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Purpose string `json:"purpose,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinedisplayname string `json:"virtualmachinedisplayname,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - Virtualmachinename string `json:"virtualmachinename,omitempty"` - Vlanid string `json:"vlanid,omitempty"` - Vlanname string `json:"vlanname,omitempty"` - Vmipaddress string `json:"vmipaddress,omitempty"` - Vpcid string `json:"vpcid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type UpdateNetworkParams struct { - p map[string]interface{} -} - -func (p *UpdateNetworkParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["changecidr"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("changecidr", vv) - } - if v, found := p.p["customid"]; found { - u.Set("customid", v.(string)) - } - if v, found := p.p["displaynetwork"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("displaynetwork", vv) - } - if v, found := p.p["displaytext"]; found { - u.Set("displaytext", v.(string)) - } - if v, found := p.p["guestvmcidr"]; found { - u.Set("guestvmcidr", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["networkdomain"]; found { - u.Set("networkdomain", v.(string)) - } - if v, found := p.p["networkofferingid"]; found { - u.Set("networkofferingid", v.(string)) - } - return u -} - -func (p *UpdateNetworkParams) SetChangecidr(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["changecidr"] = v - return -} - -func (p *UpdateNetworkParams) SetCustomid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["customid"] = v - return -} - -func (p *UpdateNetworkParams) SetDisplaynetwork(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displaynetwork"] = v - return -} - -func (p *UpdateNetworkParams) SetDisplaytext(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displaytext"] = v - return -} - -func (p *UpdateNetworkParams) SetGuestvmcidr(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["guestvmcidr"] = v - return -} - -func (p *UpdateNetworkParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateNetworkParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *UpdateNetworkParams) SetNetworkdomain(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkdomain"] = v - return -} - -func (p *UpdateNetworkParams) SetNetworkofferingid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkofferingid"] = v - return -} - -// You should always use this function to get a new UpdateNetworkParams instance, -// as then you are sure you have configured all required params -func (s *NetworkService) NewUpdateNetworkParams(id string) *UpdateNetworkParams { - p := &UpdateNetworkParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates a network -func (s *NetworkService) UpdateNetwork(p *UpdateNetworkParams) (*UpdateNetworkResponse, error) { - resp, err := s.cs.newRequest("updateNetwork", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateNetworkResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateNetworkResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Aclid string `json:"aclid,omitempty"` - Acltype string `json:"acltype,omitempty"` - Broadcastdomaintype string `json:"broadcastdomaintype,omitempty"` - Broadcasturi string `json:"broadcasturi,omitempty"` - Canusefordeploy bool `json:"canusefordeploy,omitempty"` - Cidr string `json:"cidr,omitempty"` - Displaynetwork bool `json:"displaynetwork,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Dns1 string `json:"dns1,omitempty"` - Dns2 string `json:"dns2,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Ispersistent bool `json:"ispersistent,omitempty"` - Issystem bool `json:"issystem,omitempty"` - Name string `json:"name,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkcidr string `json:"networkcidr,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Networkofferingavailability string `json:"networkofferingavailability,omitempty"` - Networkofferingconservemode bool `json:"networkofferingconservemode,omitempty"` - Networkofferingdisplaytext string `json:"networkofferingdisplaytext,omitempty"` - Networkofferingid string `json:"networkofferingid,omitempty"` - Networkofferingname string `json:"networkofferingname,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Related string `json:"related,omitempty"` - Reservediprange string `json:"reservediprange,omitempty"` - Restartrequired bool `json:"restartrequired,omitempty"` - Service []struct { - Capability []struct { - Canchooseservicecapability bool `json:"canchooseservicecapability,omitempty"` - Name string `json:"name,omitempty"` - Value string `json:"value,omitempty"` - } `json:"capability,omitempty"` - Name string `json:"name,omitempty"` - Provider []struct { - Canenableindividualservice bool `json:"canenableindividualservice,omitempty"` - Destinationphysicalnetworkid string `json:"destinationphysicalnetworkid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Servicelist []string `json:"servicelist,omitempty"` - State string `json:"state,omitempty"` - } `json:"provider,omitempty"` - } `json:"service,omitempty"` - Specifyipranges bool `json:"specifyipranges,omitempty"` - State string `json:"state,omitempty"` - Strechedl2subnet bool `json:"strechedl2subnet,omitempty"` - Subdomainaccess bool `json:"subdomainaccess,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Vlan string `json:"vlan,omitempty"` - Vpcid string `json:"vpcid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` - Zonesnetworkspans []string `json:"zonesnetworkspans,omitempty"` -} - -type CreatePhysicalNetworkParams struct { - p map[string]interface{} -} - -func (p *CreatePhysicalNetworkParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["broadcastdomainrange"]; found { - u.Set("broadcastdomainrange", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["isolationmethods"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("isolationmethods", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["networkspeed"]; found { - u.Set("networkspeed", v.(string)) - } - if v, found := p.p["tags"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("tags", vv) - } - if v, found := p.p["vlan"]; found { - u.Set("vlan", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *CreatePhysicalNetworkParams) SetBroadcastdomainrange(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["broadcastdomainrange"] = v - return -} - -func (p *CreatePhysicalNetworkParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *CreatePhysicalNetworkParams) SetIsolationmethods(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isolationmethods"] = v - return -} - -func (p *CreatePhysicalNetworkParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *CreatePhysicalNetworkParams) SetNetworkspeed(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkspeed"] = v - return -} - -func (p *CreatePhysicalNetworkParams) SetTags(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tags"] = v - return -} - -func (p *CreatePhysicalNetworkParams) SetVlan(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vlan"] = v - return -} - -func (p *CreatePhysicalNetworkParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new CreatePhysicalNetworkParams instance, -// as then you are sure you have configured all required params -func (s *NetworkService) NewCreatePhysicalNetworkParams(name string, zoneid string) *CreatePhysicalNetworkParams { - p := &CreatePhysicalNetworkParams{} - p.p = make(map[string]interface{}) - p.p["name"] = name - p.p["zoneid"] = zoneid - return p -} - -// Creates a physical network -func (s *NetworkService) CreatePhysicalNetwork(p *CreatePhysicalNetworkParams) (*CreatePhysicalNetworkResponse, error) { - resp, err := s.cs.newRequest("createPhysicalNetwork", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreatePhysicalNetworkResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreatePhysicalNetworkResponse struct { - JobID string `json:"jobid,omitempty"` - Broadcastdomainrange string `json:"broadcastdomainrange,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Isolationmethods string `json:"isolationmethods,omitempty"` - Name string `json:"name,omitempty"` - Networkspeed string `json:"networkspeed,omitempty"` - State string `json:"state,omitempty"` - Tags string `json:"tags,omitempty"` - Vlan string `json:"vlan,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type DeletePhysicalNetworkParams struct { - p map[string]interface{} -} - -func (p *DeletePhysicalNetworkParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeletePhysicalNetworkParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeletePhysicalNetworkParams instance, -// as then you are sure you have configured all required params -func (s *NetworkService) NewDeletePhysicalNetworkParams(id string) *DeletePhysicalNetworkParams { - p := &DeletePhysicalNetworkParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a Physical Network. -func (s *NetworkService) DeletePhysicalNetwork(p *DeletePhysicalNetworkParams) (*DeletePhysicalNetworkResponse, error) { - resp, err := s.cs.newRequest("deletePhysicalNetwork", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeletePhysicalNetworkResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeletePhysicalNetworkResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListPhysicalNetworksParams struct { - p map[string]interface{} -} - -func (p *ListPhysicalNetworksParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ListPhysicalNetworksParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListPhysicalNetworksParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListPhysicalNetworksParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListPhysicalNetworksParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListPhysicalNetworksParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListPhysicalNetworksParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ListPhysicalNetworksParams instance, -// as then you are sure you have configured all required params -func (s *NetworkService) NewListPhysicalNetworksParams() *ListPhysicalNetworksParams { - p := &ListPhysicalNetworksParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *NetworkService) GetPhysicalNetworkID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListPhysicalNetworksParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListPhysicalNetworks(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.PhysicalNetworks[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.PhysicalNetworks { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *NetworkService) GetPhysicalNetworkByName(name string, opts ...OptionFunc) (*PhysicalNetwork, int, error) { - id, count, err := s.GetPhysicalNetworkID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetPhysicalNetworkByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *NetworkService) GetPhysicalNetworkByID(id string, opts ...OptionFunc) (*PhysicalNetwork, int, error) { - p := &ListPhysicalNetworksParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListPhysicalNetworks(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.PhysicalNetworks[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for PhysicalNetwork UUID: %s!", id) -} - -// Lists physical networks -func (s *NetworkService) ListPhysicalNetworks(p *ListPhysicalNetworksParams) (*ListPhysicalNetworksResponse, error) { - resp, err := s.cs.newRequest("listPhysicalNetworks", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListPhysicalNetworksResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListPhysicalNetworksResponse struct { - Count int `json:"count"` - PhysicalNetworks []*PhysicalNetwork `json:"physicalnetwork"` -} - -type PhysicalNetwork struct { - Broadcastdomainrange string `json:"broadcastdomainrange,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Isolationmethods string `json:"isolationmethods,omitempty"` - Name string `json:"name,omitempty"` - Networkspeed string `json:"networkspeed,omitempty"` - State string `json:"state,omitempty"` - Tags string `json:"tags,omitempty"` - Vlan string `json:"vlan,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type UpdatePhysicalNetworkParams struct { - p map[string]interface{} -} - -func (p *UpdatePhysicalNetworkParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["networkspeed"]; found { - u.Set("networkspeed", v.(string)) - } - if v, found := p.p["state"]; found { - u.Set("state", v.(string)) - } - if v, found := p.p["tags"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("tags", vv) - } - if v, found := p.p["vlan"]; found { - u.Set("vlan", v.(string)) - } - return u -} - -func (p *UpdatePhysicalNetworkParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdatePhysicalNetworkParams) SetNetworkspeed(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkspeed"] = v - return -} - -func (p *UpdatePhysicalNetworkParams) SetState(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["state"] = v - return -} - -func (p *UpdatePhysicalNetworkParams) SetTags(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tags"] = v - return -} - -func (p *UpdatePhysicalNetworkParams) SetVlan(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vlan"] = v - return -} - -// You should always use this function to get a new UpdatePhysicalNetworkParams instance, -// as then you are sure you have configured all required params -func (s *NetworkService) NewUpdatePhysicalNetworkParams(id string) *UpdatePhysicalNetworkParams { - p := &UpdatePhysicalNetworkParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates a physical network -func (s *NetworkService) UpdatePhysicalNetwork(p *UpdatePhysicalNetworkParams) (*UpdatePhysicalNetworkResponse, error) { - resp, err := s.cs.newRequest("updatePhysicalNetwork", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdatePhysicalNetworkResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdatePhysicalNetworkResponse struct { - JobID string `json:"jobid,omitempty"` - Broadcastdomainrange string `json:"broadcastdomainrange,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Isolationmethods string `json:"isolationmethods,omitempty"` - Name string `json:"name,omitempty"` - Networkspeed string `json:"networkspeed,omitempty"` - State string `json:"state,omitempty"` - Tags string `json:"tags,omitempty"` - Vlan string `json:"vlan,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type ListSupportedNetworkServicesParams struct { - p map[string]interface{} -} - -func (p *ListSupportedNetworkServicesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["provider"]; found { - u.Set("provider", v.(string)) - } - if v, found := p.p["service"]; found { - u.Set("service", v.(string)) - } - return u -} - -func (p *ListSupportedNetworkServicesParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListSupportedNetworkServicesParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListSupportedNetworkServicesParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListSupportedNetworkServicesParams) SetProvider(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["provider"] = v - return -} - -func (p *ListSupportedNetworkServicesParams) SetService(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["service"] = v - return -} - -// You should always use this function to get a new ListSupportedNetworkServicesParams instance, -// as then you are sure you have configured all required params -func (s *NetworkService) NewListSupportedNetworkServicesParams() *ListSupportedNetworkServicesParams { - p := &ListSupportedNetworkServicesParams{} - p.p = make(map[string]interface{}) - return p -} - -// Lists all network services provided by CloudStack or for the given Provider. -func (s *NetworkService) ListSupportedNetworkServices(p *ListSupportedNetworkServicesParams) (*ListSupportedNetworkServicesResponse, error) { - resp, err := s.cs.newRequest("listSupportedNetworkServices", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListSupportedNetworkServicesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListSupportedNetworkServicesResponse struct { - Count int `json:"count"` - SupportedNetworkServices []*SupportedNetworkService `json:"supportednetworkservice"` -} - -type SupportedNetworkService struct { - Capability []struct { - Canchooseservicecapability bool `json:"canchooseservicecapability,omitempty"` - Name string `json:"name,omitempty"` - Value string `json:"value,omitempty"` - } `json:"capability,omitempty"` - Name string `json:"name,omitempty"` - Provider []struct { - Canenableindividualservice bool `json:"canenableindividualservice,omitempty"` - Destinationphysicalnetworkid string `json:"destinationphysicalnetworkid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Servicelist []string `json:"servicelist,omitempty"` - State string `json:"state,omitempty"` - } `json:"provider,omitempty"` -} - -type AddNetworkServiceProviderParams struct { - p map[string]interface{} -} - -func (p *AddNetworkServiceProviderParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["destinationphysicalnetworkid"]; found { - u.Set("destinationphysicalnetworkid", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["physicalnetworkid"]; found { - u.Set("physicalnetworkid", v.(string)) - } - if v, found := p.p["servicelist"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("servicelist", vv) - } - return u -} - -func (p *AddNetworkServiceProviderParams) SetDestinationphysicalnetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["destinationphysicalnetworkid"] = v - return -} - -func (p *AddNetworkServiceProviderParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *AddNetworkServiceProviderParams) SetPhysicalnetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["physicalnetworkid"] = v - return -} - -func (p *AddNetworkServiceProviderParams) SetServicelist(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["servicelist"] = v - return -} - -// You should always use this function to get a new AddNetworkServiceProviderParams instance, -// as then you are sure you have configured all required params -func (s *NetworkService) NewAddNetworkServiceProviderParams(name string, physicalnetworkid string) *AddNetworkServiceProviderParams { - p := &AddNetworkServiceProviderParams{} - p.p = make(map[string]interface{}) - p.p["name"] = name - p.p["physicalnetworkid"] = physicalnetworkid - return p -} - -// Adds a network serviceProvider to a physical network -func (s *NetworkService) AddNetworkServiceProvider(p *AddNetworkServiceProviderParams) (*AddNetworkServiceProviderResponse, error) { - resp, err := s.cs.newRequest("addNetworkServiceProvider", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AddNetworkServiceProviderResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type AddNetworkServiceProviderResponse struct { - JobID string `json:"jobid,omitempty"` - Canenableindividualservice bool `json:"canenableindividualservice,omitempty"` - Destinationphysicalnetworkid string `json:"destinationphysicalnetworkid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Servicelist []string `json:"servicelist,omitempty"` - State string `json:"state,omitempty"` -} - -type DeleteNetworkServiceProviderParams struct { - p map[string]interface{} -} - -func (p *DeleteNetworkServiceProviderParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteNetworkServiceProviderParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteNetworkServiceProviderParams instance, -// as then you are sure you have configured all required params -func (s *NetworkService) NewDeleteNetworkServiceProviderParams(id string) *DeleteNetworkServiceProviderParams { - p := &DeleteNetworkServiceProviderParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a Network Service Provider. -func (s *NetworkService) DeleteNetworkServiceProvider(p *DeleteNetworkServiceProviderParams) (*DeleteNetworkServiceProviderResponse, error) { - resp, err := s.cs.newRequest("deleteNetworkServiceProvider", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteNetworkServiceProviderResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteNetworkServiceProviderResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListNetworkServiceProvidersParams struct { - p map[string]interface{} -} - -func (p *ListNetworkServiceProvidersParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["physicalnetworkid"]; found { - u.Set("physicalnetworkid", v.(string)) - } - if v, found := p.p["state"]; found { - u.Set("state", v.(string)) - } - return u -} - -func (p *ListNetworkServiceProvidersParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListNetworkServiceProvidersParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListNetworkServiceProvidersParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListNetworkServiceProvidersParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListNetworkServiceProvidersParams) SetPhysicalnetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["physicalnetworkid"] = v - return -} - -func (p *ListNetworkServiceProvidersParams) SetState(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["state"] = v - return -} - -// You should always use this function to get a new ListNetworkServiceProvidersParams instance, -// as then you are sure you have configured all required params -func (s *NetworkService) NewListNetworkServiceProvidersParams() *ListNetworkServiceProvidersParams { - p := &ListNetworkServiceProvidersParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *NetworkService) GetNetworkServiceProviderID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListNetworkServiceProvidersParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListNetworkServiceProviders(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.NetworkServiceProviders[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.NetworkServiceProviders { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// Lists network serviceproviders for a given physical network. -func (s *NetworkService) ListNetworkServiceProviders(p *ListNetworkServiceProvidersParams) (*ListNetworkServiceProvidersResponse, error) { - resp, err := s.cs.newRequest("listNetworkServiceProviders", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListNetworkServiceProvidersResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListNetworkServiceProvidersResponse struct { - Count int `json:"count"` - NetworkServiceProviders []*NetworkServiceProvider `json:"networkserviceprovider"` -} - -type NetworkServiceProvider struct { - Canenableindividualservice bool `json:"canenableindividualservice,omitempty"` - Destinationphysicalnetworkid string `json:"destinationphysicalnetworkid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Servicelist []string `json:"servicelist,omitempty"` - State string `json:"state,omitempty"` -} - -type UpdateNetworkServiceProviderParams struct { - p map[string]interface{} -} - -func (p *UpdateNetworkServiceProviderParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["servicelist"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("servicelist", vv) - } - if v, found := p.p["state"]; found { - u.Set("state", v.(string)) - } - return u -} - -func (p *UpdateNetworkServiceProviderParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateNetworkServiceProviderParams) SetServicelist(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["servicelist"] = v - return -} - -func (p *UpdateNetworkServiceProviderParams) SetState(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["state"] = v - return -} - -// You should always use this function to get a new UpdateNetworkServiceProviderParams instance, -// as then you are sure you have configured all required params -func (s *NetworkService) NewUpdateNetworkServiceProviderParams(id string) *UpdateNetworkServiceProviderParams { - p := &UpdateNetworkServiceProviderParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates a network serviceProvider of a physical network -func (s *NetworkService) UpdateNetworkServiceProvider(p *UpdateNetworkServiceProviderParams) (*UpdateNetworkServiceProviderResponse, error) { - resp, err := s.cs.newRequest("updateNetworkServiceProvider", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateNetworkServiceProviderResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateNetworkServiceProviderResponse struct { - JobID string `json:"jobid,omitempty"` - Canenableindividualservice bool `json:"canenableindividualservice,omitempty"` - Destinationphysicalnetworkid string `json:"destinationphysicalnetworkid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Servicelist []string `json:"servicelist,omitempty"` - State string `json:"state,omitempty"` -} - -type CreateStorageNetworkIpRangeParams struct { - p map[string]interface{} -} - -func (p *CreateStorageNetworkIpRangeParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["endip"]; found { - u.Set("endip", v.(string)) - } - if v, found := p.p["gateway"]; found { - u.Set("gateway", v.(string)) - } - if v, found := p.p["netmask"]; found { - u.Set("netmask", v.(string)) - } - if v, found := p.p["podid"]; found { - u.Set("podid", v.(string)) - } - if v, found := p.p["startip"]; found { - u.Set("startip", v.(string)) - } - if v, found := p.p["vlan"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("vlan", vv) - } - return u -} - -func (p *CreateStorageNetworkIpRangeParams) SetEndip(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["endip"] = v - return -} - -func (p *CreateStorageNetworkIpRangeParams) SetGateway(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["gateway"] = v - return -} - -func (p *CreateStorageNetworkIpRangeParams) SetNetmask(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["netmask"] = v - return -} - -func (p *CreateStorageNetworkIpRangeParams) SetPodid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["podid"] = v - return -} - -func (p *CreateStorageNetworkIpRangeParams) SetStartip(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["startip"] = v - return -} - -func (p *CreateStorageNetworkIpRangeParams) SetVlan(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vlan"] = v - return -} - -// You should always use this function to get a new CreateStorageNetworkIpRangeParams instance, -// as then you are sure you have configured all required params -func (s *NetworkService) NewCreateStorageNetworkIpRangeParams(gateway string, netmask string, podid string, startip string) *CreateStorageNetworkIpRangeParams { - p := &CreateStorageNetworkIpRangeParams{} - p.p = make(map[string]interface{}) - p.p["gateway"] = gateway - p.p["netmask"] = netmask - p.p["podid"] = podid - p.p["startip"] = startip - return p -} - -// Creates a Storage network IP range. -func (s *NetworkService) CreateStorageNetworkIpRange(p *CreateStorageNetworkIpRangeParams) (*CreateStorageNetworkIpRangeResponse, error) { - resp, err := s.cs.newRequest("createStorageNetworkIpRange", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateStorageNetworkIpRangeResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateStorageNetworkIpRangeResponse struct { - JobID string `json:"jobid,omitempty"` - Endip string `json:"endip,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Podid string `json:"podid,omitempty"` - Startip string `json:"startip,omitempty"` - Vlan int `json:"vlan,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type DeleteStorageNetworkIpRangeParams struct { - p map[string]interface{} -} - -func (p *DeleteStorageNetworkIpRangeParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteStorageNetworkIpRangeParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteStorageNetworkIpRangeParams instance, -// as then you are sure you have configured all required params -func (s *NetworkService) NewDeleteStorageNetworkIpRangeParams(id string) *DeleteStorageNetworkIpRangeParams { - p := &DeleteStorageNetworkIpRangeParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a storage network IP Range. -func (s *NetworkService) DeleteStorageNetworkIpRange(p *DeleteStorageNetworkIpRangeParams) (*DeleteStorageNetworkIpRangeResponse, error) { - resp, err := s.cs.newRequest("deleteStorageNetworkIpRange", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteStorageNetworkIpRangeResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteStorageNetworkIpRangeResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListStorageNetworkIpRangeParams struct { - p map[string]interface{} -} - -func (p *ListStorageNetworkIpRangeParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["podid"]; found { - u.Set("podid", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ListStorageNetworkIpRangeParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListStorageNetworkIpRangeParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListStorageNetworkIpRangeParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListStorageNetworkIpRangeParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListStorageNetworkIpRangeParams) SetPodid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["podid"] = v - return -} - -func (p *ListStorageNetworkIpRangeParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ListStorageNetworkIpRangeParams instance, -// as then you are sure you have configured all required params -func (s *NetworkService) NewListStorageNetworkIpRangeParams() *ListStorageNetworkIpRangeParams { - p := &ListStorageNetworkIpRangeParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *NetworkService) GetStorageNetworkIpRangeByID(id string, opts ...OptionFunc) (*StorageNetworkIpRange, int, error) { - p := &ListStorageNetworkIpRangeParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListStorageNetworkIpRange(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.StorageNetworkIpRange[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for StorageNetworkIpRange UUID: %s!", id) -} - -// List a storage network IP range. -func (s *NetworkService) ListStorageNetworkIpRange(p *ListStorageNetworkIpRangeParams) (*ListStorageNetworkIpRangeResponse, error) { - resp, err := s.cs.newRequest("listStorageNetworkIpRange", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListStorageNetworkIpRangeResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListStorageNetworkIpRangeResponse struct { - Count int `json:"count"` - StorageNetworkIpRange []*StorageNetworkIpRange `json:"storagenetworkiprange"` -} - -type StorageNetworkIpRange struct { - Endip string `json:"endip,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Podid string `json:"podid,omitempty"` - Startip string `json:"startip,omitempty"` - Vlan int `json:"vlan,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type UpdateStorageNetworkIpRangeParams struct { - p map[string]interface{} -} - -func (p *UpdateStorageNetworkIpRangeParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["endip"]; found { - u.Set("endip", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["netmask"]; found { - u.Set("netmask", v.(string)) - } - if v, found := p.p["startip"]; found { - u.Set("startip", v.(string)) - } - if v, found := p.p["vlan"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("vlan", vv) - } - return u -} - -func (p *UpdateStorageNetworkIpRangeParams) SetEndip(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["endip"] = v - return -} - -func (p *UpdateStorageNetworkIpRangeParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateStorageNetworkIpRangeParams) SetNetmask(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["netmask"] = v - return -} - -func (p *UpdateStorageNetworkIpRangeParams) SetStartip(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["startip"] = v - return -} - -func (p *UpdateStorageNetworkIpRangeParams) SetVlan(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vlan"] = v - return -} - -// You should always use this function to get a new UpdateStorageNetworkIpRangeParams instance, -// as then you are sure you have configured all required params -func (s *NetworkService) NewUpdateStorageNetworkIpRangeParams(id string) *UpdateStorageNetworkIpRangeParams { - p := &UpdateStorageNetworkIpRangeParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Update a Storage network IP range, only allowed when no IPs in this range have been allocated. -func (s *NetworkService) UpdateStorageNetworkIpRange(p *UpdateStorageNetworkIpRangeParams) (*UpdateStorageNetworkIpRangeResponse, error) { - resp, err := s.cs.newRequest("updateStorageNetworkIpRange", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateStorageNetworkIpRangeResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateStorageNetworkIpRangeResponse struct { - JobID string `json:"jobid,omitempty"` - Endip string `json:"endip,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Podid string `json:"podid,omitempty"` - Startip string `json:"startip,omitempty"` - Vlan int `json:"vlan,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type ListPaloAltoFirewallNetworksParams struct { - p map[string]interface{} -} - -func (p *ListPaloAltoFirewallNetworksParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["lbdeviceid"]; found { - u.Set("lbdeviceid", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - return u -} - -func (p *ListPaloAltoFirewallNetworksParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListPaloAltoFirewallNetworksParams) SetLbdeviceid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["lbdeviceid"] = v - return -} - -func (p *ListPaloAltoFirewallNetworksParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListPaloAltoFirewallNetworksParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -// You should always use this function to get a new ListPaloAltoFirewallNetworksParams instance, -// as then you are sure you have configured all required params -func (s *NetworkService) NewListPaloAltoFirewallNetworksParams(lbdeviceid string) *ListPaloAltoFirewallNetworksParams { - p := &ListPaloAltoFirewallNetworksParams{} - p.p = make(map[string]interface{}) - p.p["lbdeviceid"] = lbdeviceid - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *NetworkService) GetPaloAltoFirewallNetworkID(keyword string, lbdeviceid string, opts ...OptionFunc) (string, int, error) { - p := &ListPaloAltoFirewallNetworksParams{} - p.p = make(map[string]interface{}) - - p.p["keyword"] = keyword - p.p["lbdeviceid"] = lbdeviceid - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListPaloAltoFirewallNetworks(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", keyword, l) - } - - if l.Count == 1 { - return l.PaloAltoFirewallNetworks[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.PaloAltoFirewallNetworks { - if v.Name == keyword { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l) -} - -// lists network that are using Palo Alto firewall device -func (s *NetworkService) ListPaloAltoFirewallNetworks(p *ListPaloAltoFirewallNetworksParams) (*ListPaloAltoFirewallNetworksResponse, error) { - resp, err := s.cs.newRequest("listPaloAltoFirewallNetworks", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListPaloAltoFirewallNetworksResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListPaloAltoFirewallNetworksResponse struct { - Count int `json:"count"` - PaloAltoFirewallNetworks []*PaloAltoFirewallNetwork `json:"paloaltofirewallnetwork"` -} - -type PaloAltoFirewallNetwork struct { - Account string `json:"account,omitempty"` - Aclid string `json:"aclid,omitempty"` - Acltype string `json:"acltype,omitempty"` - Broadcastdomaintype string `json:"broadcastdomaintype,omitempty"` - Broadcasturi string `json:"broadcasturi,omitempty"` - Canusefordeploy bool `json:"canusefordeploy,omitempty"` - Cidr string `json:"cidr,omitempty"` - Displaynetwork bool `json:"displaynetwork,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Dns1 string `json:"dns1,omitempty"` - Dns2 string `json:"dns2,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Ispersistent bool `json:"ispersistent,omitempty"` - Issystem bool `json:"issystem,omitempty"` - Name string `json:"name,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkcidr string `json:"networkcidr,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Networkofferingavailability string `json:"networkofferingavailability,omitempty"` - Networkofferingconservemode bool `json:"networkofferingconservemode,omitempty"` - Networkofferingdisplaytext string `json:"networkofferingdisplaytext,omitempty"` - Networkofferingid string `json:"networkofferingid,omitempty"` - Networkofferingname string `json:"networkofferingname,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Related string `json:"related,omitempty"` - Reservediprange string `json:"reservediprange,omitempty"` - Restartrequired bool `json:"restartrequired,omitempty"` - Service []struct { - Capability []struct { - Canchooseservicecapability bool `json:"canchooseservicecapability,omitempty"` - Name string `json:"name,omitempty"` - Value string `json:"value,omitempty"` - } `json:"capability,omitempty"` - Name string `json:"name,omitempty"` - Provider []struct { - Canenableindividualservice bool `json:"canenableindividualservice,omitempty"` - Destinationphysicalnetworkid string `json:"destinationphysicalnetworkid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Servicelist []string `json:"servicelist,omitempty"` - State string `json:"state,omitempty"` - } `json:"provider,omitempty"` - } `json:"service,omitempty"` - Specifyipranges bool `json:"specifyipranges,omitempty"` - State string `json:"state,omitempty"` - Strechedl2subnet bool `json:"strechedl2subnet,omitempty"` - Subdomainaccess bool `json:"subdomainaccess,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Vlan string `json:"vlan,omitempty"` - Vpcid string `json:"vpcid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` - Zonesnetworkspans []string `json:"zonesnetworkspans,omitempty"` -} - -type ListNetscalerLoadBalancerNetworksParams struct { - p map[string]interface{} -} - -func (p *ListNetscalerLoadBalancerNetworksParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["lbdeviceid"]; found { - u.Set("lbdeviceid", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - return u -} - -func (p *ListNetscalerLoadBalancerNetworksParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListNetscalerLoadBalancerNetworksParams) SetLbdeviceid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["lbdeviceid"] = v - return -} - -func (p *ListNetscalerLoadBalancerNetworksParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListNetscalerLoadBalancerNetworksParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -// You should always use this function to get a new ListNetscalerLoadBalancerNetworksParams instance, -// as then you are sure you have configured all required params -func (s *NetworkService) NewListNetscalerLoadBalancerNetworksParams(lbdeviceid string) *ListNetscalerLoadBalancerNetworksParams { - p := &ListNetscalerLoadBalancerNetworksParams{} - p.p = make(map[string]interface{}) - p.p["lbdeviceid"] = lbdeviceid - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *NetworkService) GetNetscalerLoadBalancerNetworkID(keyword string, lbdeviceid string, opts ...OptionFunc) (string, int, error) { - p := &ListNetscalerLoadBalancerNetworksParams{} - p.p = make(map[string]interface{}) - - p.p["keyword"] = keyword - p.p["lbdeviceid"] = lbdeviceid - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListNetscalerLoadBalancerNetworks(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", keyword, l) - } - - if l.Count == 1 { - return l.NetscalerLoadBalancerNetworks[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.NetscalerLoadBalancerNetworks { - if v.Name == keyword { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l) -} - -// lists network that are using a netscaler load balancer device -func (s *NetworkService) ListNetscalerLoadBalancerNetworks(p *ListNetscalerLoadBalancerNetworksParams) (*ListNetscalerLoadBalancerNetworksResponse, error) { - resp, err := s.cs.newRequest("listNetscalerLoadBalancerNetworks", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListNetscalerLoadBalancerNetworksResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListNetscalerLoadBalancerNetworksResponse struct { - Count int `json:"count"` - NetscalerLoadBalancerNetworks []*NetscalerLoadBalancerNetwork `json:"netscalerloadbalancernetwork"` -} - -type NetscalerLoadBalancerNetwork struct { - Account string `json:"account,omitempty"` - Aclid string `json:"aclid,omitempty"` - Acltype string `json:"acltype,omitempty"` - Broadcastdomaintype string `json:"broadcastdomaintype,omitempty"` - Broadcasturi string `json:"broadcasturi,omitempty"` - Canusefordeploy bool `json:"canusefordeploy,omitempty"` - Cidr string `json:"cidr,omitempty"` - Displaynetwork bool `json:"displaynetwork,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Dns1 string `json:"dns1,omitempty"` - Dns2 string `json:"dns2,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Ispersistent bool `json:"ispersistent,omitempty"` - Issystem bool `json:"issystem,omitempty"` - Name string `json:"name,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkcidr string `json:"networkcidr,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Networkofferingavailability string `json:"networkofferingavailability,omitempty"` - Networkofferingconservemode bool `json:"networkofferingconservemode,omitempty"` - Networkofferingdisplaytext string `json:"networkofferingdisplaytext,omitempty"` - Networkofferingid string `json:"networkofferingid,omitempty"` - Networkofferingname string `json:"networkofferingname,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Related string `json:"related,omitempty"` - Reservediprange string `json:"reservediprange,omitempty"` - Restartrequired bool `json:"restartrequired,omitempty"` - Service []struct { - Capability []struct { - Canchooseservicecapability bool `json:"canchooseservicecapability,omitempty"` - Name string `json:"name,omitempty"` - Value string `json:"value,omitempty"` - } `json:"capability,omitempty"` - Name string `json:"name,omitempty"` - Provider []struct { - Canenableindividualservice bool `json:"canenableindividualservice,omitempty"` - Destinationphysicalnetworkid string `json:"destinationphysicalnetworkid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Servicelist []string `json:"servicelist,omitempty"` - State string `json:"state,omitempty"` - } `json:"provider,omitempty"` - } `json:"service,omitempty"` - Specifyipranges bool `json:"specifyipranges,omitempty"` - State string `json:"state,omitempty"` - Strechedl2subnet bool `json:"strechedl2subnet,omitempty"` - Subdomainaccess bool `json:"subdomainaccess,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Vlan string `json:"vlan,omitempty"` - Vpcid string `json:"vpcid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` - Zonesnetworkspans []string `json:"zonesnetworkspans,omitempty"` -} - -type ListNiciraNvpDeviceNetworksParams struct { - p map[string]interface{} -} - -func (p *ListNiciraNvpDeviceNetworksParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["nvpdeviceid"]; found { - u.Set("nvpdeviceid", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - return u -} - -func (p *ListNiciraNvpDeviceNetworksParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListNiciraNvpDeviceNetworksParams) SetNvpdeviceid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["nvpdeviceid"] = v - return -} - -func (p *ListNiciraNvpDeviceNetworksParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListNiciraNvpDeviceNetworksParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -// You should always use this function to get a new ListNiciraNvpDeviceNetworksParams instance, -// as then you are sure you have configured all required params -func (s *NetworkService) NewListNiciraNvpDeviceNetworksParams(nvpdeviceid string) *ListNiciraNvpDeviceNetworksParams { - p := &ListNiciraNvpDeviceNetworksParams{} - p.p = make(map[string]interface{}) - p.p["nvpdeviceid"] = nvpdeviceid - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *NetworkService) GetNiciraNvpDeviceNetworkID(keyword string, nvpdeviceid string, opts ...OptionFunc) (string, int, error) { - p := &ListNiciraNvpDeviceNetworksParams{} - p.p = make(map[string]interface{}) - - p.p["keyword"] = keyword - p.p["nvpdeviceid"] = nvpdeviceid - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListNiciraNvpDeviceNetworks(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", keyword, l) - } - - if l.Count == 1 { - return l.NiciraNvpDeviceNetworks[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.NiciraNvpDeviceNetworks { - if v.Name == keyword { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l) -} - -// lists network that are using a nicira nvp device -func (s *NetworkService) ListNiciraNvpDeviceNetworks(p *ListNiciraNvpDeviceNetworksParams) (*ListNiciraNvpDeviceNetworksResponse, error) { - resp, err := s.cs.newRequest("listNiciraNvpDeviceNetworks", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListNiciraNvpDeviceNetworksResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListNiciraNvpDeviceNetworksResponse struct { - Count int `json:"count"` - NiciraNvpDeviceNetworks []*NiciraNvpDeviceNetwork `json:"niciranvpdevicenetwork"` -} - -type NiciraNvpDeviceNetwork struct { - Account string `json:"account,omitempty"` - Aclid string `json:"aclid,omitempty"` - Acltype string `json:"acltype,omitempty"` - Broadcastdomaintype string `json:"broadcastdomaintype,omitempty"` - Broadcasturi string `json:"broadcasturi,omitempty"` - Canusefordeploy bool `json:"canusefordeploy,omitempty"` - Cidr string `json:"cidr,omitempty"` - Displaynetwork bool `json:"displaynetwork,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Dns1 string `json:"dns1,omitempty"` - Dns2 string `json:"dns2,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Ispersistent bool `json:"ispersistent,omitempty"` - Issystem bool `json:"issystem,omitempty"` - Name string `json:"name,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkcidr string `json:"networkcidr,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Networkofferingavailability string `json:"networkofferingavailability,omitempty"` - Networkofferingconservemode bool `json:"networkofferingconservemode,omitempty"` - Networkofferingdisplaytext string `json:"networkofferingdisplaytext,omitempty"` - Networkofferingid string `json:"networkofferingid,omitempty"` - Networkofferingname string `json:"networkofferingname,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Related string `json:"related,omitempty"` - Reservediprange string `json:"reservediprange,omitempty"` - Restartrequired bool `json:"restartrequired,omitempty"` - Service []struct { - Capability []struct { - Canchooseservicecapability bool `json:"canchooseservicecapability,omitempty"` - Name string `json:"name,omitempty"` - Value string `json:"value,omitempty"` - } `json:"capability,omitempty"` - Name string `json:"name,omitempty"` - Provider []struct { - Canenableindividualservice bool `json:"canenableindividualservice,omitempty"` - Destinationphysicalnetworkid string `json:"destinationphysicalnetworkid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Servicelist []string `json:"servicelist,omitempty"` - State string `json:"state,omitempty"` - } `json:"provider,omitempty"` - } `json:"service,omitempty"` - Specifyipranges bool `json:"specifyipranges,omitempty"` - State string `json:"state,omitempty"` - Strechedl2subnet bool `json:"strechedl2subnet,omitempty"` - Subdomainaccess bool `json:"subdomainaccess,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Vlan string `json:"vlan,omitempty"` - Vpcid string `json:"vpcid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` - Zonesnetworkspans []string `json:"zonesnetworkspans,omitempty"` -} - -type ListNetworkIsolationMethodsParams struct { - p map[string]interface{} -} - -func (p *ListNetworkIsolationMethodsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - return u -} - -func (p *ListNetworkIsolationMethodsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListNetworkIsolationMethodsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListNetworkIsolationMethodsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -// You should always use this function to get a new ListNetworkIsolationMethodsParams instance, -// as then you are sure you have configured all required params -func (s *NetworkService) NewListNetworkIsolationMethodsParams() *ListNetworkIsolationMethodsParams { - p := &ListNetworkIsolationMethodsParams{} - p.p = make(map[string]interface{}) - return p -} - -// Lists supported methods of network isolation -func (s *NetworkService) ListNetworkIsolationMethods(p *ListNetworkIsolationMethodsParams) (*ListNetworkIsolationMethodsResponse, error) { - resp, err := s.cs.newRequest("listNetworkIsolationMethods", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListNetworkIsolationMethodsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListNetworkIsolationMethodsResponse struct { - Count int `json:"count"` - NetworkIsolationMethods []*NetworkIsolationMethod `json:"networkisolationmethod"` -} - -type NetworkIsolationMethod struct { - Name string `json:"name,omitempty"` -} - -type AddOpenDaylightControllerParams struct { - p map[string]interface{} -} - -func (p *AddOpenDaylightControllerParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["password"]; found { - u.Set("password", v.(string)) - } - if v, found := p.p["physicalnetworkid"]; found { - u.Set("physicalnetworkid", v.(string)) - } - if v, found := p.p["url"]; found { - u.Set("url", v.(string)) - } - if v, found := p.p["username"]; found { - u.Set("username", v.(string)) - } - return u -} - -func (p *AddOpenDaylightControllerParams) SetPassword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["password"] = v - return -} - -func (p *AddOpenDaylightControllerParams) SetPhysicalnetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["physicalnetworkid"] = v - return -} - -func (p *AddOpenDaylightControllerParams) SetUrl(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["url"] = v - return -} - -func (p *AddOpenDaylightControllerParams) SetUsername(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["username"] = v - return -} - -// You should always use this function to get a new AddOpenDaylightControllerParams instance, -// as then you are sure you have configured all required params -func (s *NetworkService) NewAddOpenDaylightControllerParams(password string, physicalnetworkid string, url string, username string) *AddOpenDaylightControllerParams { - p := &AddOpenDaylightControllerParams{} - p.p = make(map[string]interface{}) - p.p["password"] = password - p.p["physicalnetworkid"] = physicalnetworkid - p.p["url"] = url - p.p["username"] = username - return p -} - -// Adds an OpenDyalight controler -func (s *NetworkService) AddOpenDaylightController(p *AddOpenDaylightControllerParams) (*AddOpenDaylightControllerResponse, error) { - resp, err := s.cs.newRequest("addOpenDaylightController", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AddOpenDaylightControllerResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type AddOpenDaylightControllerResponse struct { - JobID string `json:"jobid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Url string `json:"url,omitempty"` - Username string `json:"username,omitempty"` -} - -type DeleteOpenDaylightControllerParams struct { - p map[string]interface{} -} - -func (p *DeleteOpenDaylightControllerParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteOpenDaylightControllerParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteOpenDaylightControllerParams instance, -// as then you are sure you have configured all required params -func (s *NetworkService) NewDeleteOpenDaylightControllerParams(id string) *DeleteOpenDaylightControllerParams { - p := &DeleteOpenDaylightControllerParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Removes an OpenDyalight controler -func (s *NetworkService) DeleteOpenDaylightController(p *DeleteOpenDaylightControllerParams) (*DeleteOpenDaylightControllerResponse, error) { - resp, err := s.cs.newRequest("deleteOpenDaylightController", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteOpenDaylightControllerResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteOpenDaylightControllerResponse struct { - JobID string `json:"jobid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Url string `json:"url,omitempty"` - Username string `json:"username,omitempty"` -} - -type ListOpenDaylightControllersParams struct { - p map[string]interface{} -} - -func (p *ListOpenDaylightControllersParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["physicalnetworkid"]; found { - u.Set("physicalnetworkid", v.(string)) - } - return u -} - -func (p *ListOpenDaylightControllersParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListOpenDaylightControllersParams) SetPhysicalnetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["physicalnetworkid"] = v - return -} - -// You should always use this function to get a new ListOpenDaylightControllersParams instance, -// as then you are sure you have configured all required params -func (s *NetworkService) NewListOpenDaylightControllersParams() *ListOpenDaylightControllersParams { - p := &ListOpenDaylightControllersParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *NetworkService) GetOpenDaylightControllerByID(id string, opts ...OptionFunc) (*OpenDaylightController, int, error) { - p := &ListOpenDaylightControllersParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListOpenDaylightControllers(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.OpenDaylightControllers[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for OpenDaylightController UUID: %s!", id) -} - -// Lists OpenDyalight controllers -func (s *NetworkService) ListOpenDaylightControllers(p *ListOpenDaylightControllersParams) (*ListOpenDaylightControllersResponse, error) { - resp, err := s.cs.newRequest("listOpenDaylightControllers", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListOpenDaylightControllersResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListOpenDaylightControllersResponse struct { - Count int `json:"count"` - OpenDaylightControllers []*OpenDaylightController `json:"opendaylightcontroller"` -} - -type OpenDaylightController struct { - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Url string `json:"url,omitempty"` - Username string `json:"username,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/NicService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/NicService.go deleted file mode 100644 index d83e07567e6..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/NicService.go +++ /dev/null @@ -1,574 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "net/url" - "strconv" -) - -type AddIpToNicParams struct { - p map[string]interface{} -} - -func (p *AddIpToNicParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["ipaddress"]; found { - u.Set("ipaddress", v.(string)) - } - if v, found := p.p["nicid"]; found { - u.Set("nicid", v.(string)) - } - return u -} - -func (p *AddIpToNicParams) SetIpaddress(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ipaddress"] = v - return -} - -func (p *AddIpToNicParams) SetNicid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["nicid"] = v - return -} - -// You should always use this function to get a new AddIpToNicParams instance, -// as then you are sure you have configured all required params -func (s *NicService) NewAddIpToNicParams(nicid string) *AddIpToNicParams { - p := &AddIpToNicParams{} - p.p = make(map[string]interface{}) - p.p["nicid"] = nicid - return p -} - -// Assigns secondary IP to NIC -func (s *NicService) AddIpToNic(p *AddIpToNicParams) (*AddIpToNicResponse, error) { - resp, err := s.cs.newRequest("addIpToNic", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AddIpToNicResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type AddIpToNicResponse struct { - JobID string `json:"jobid,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Networkid string `json:"networkid,omitempty"` - Nicid string `json:"nicid,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` -} - -type RemoveIpFromNicParams struct { - p map[string]interface{} -} - -func (p *RemoveIpFromNicParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *RemoveIpFromNicParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new RemoveIpFromNicParams instance, -// as then you are sure you have configured all required params -func (s *NicService) NewRemoveIpFromNicParams(id string) *RemoveIpFromNicParams { - p := &RemoveIpFromNicParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Removes secondary IP from the NIC. -func (s *NicService) RemoveIpFromNic(p *RemoveIpFromNicParams) (*RemoveIpFromNicResponse, error) { - resp, err := s.cs.newRequest("removeIpFromNic", p.toURLValues()) - if err != nil { - return nil, err - } - - var r RemoveIpFromNicResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type RemoveIpFromNicResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type UpdateVmNicIpParams struct { - p map[string]interface{} -} - -func (p *UpdateVmNicIpParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["ipaddress"]; found { - u.Set("ipaddress", v.(string)) - } - if v, found := p.p["nicid"]; found { - u.Set("nicid", v.(string)) - } - return u -} - -func (p *UpdateVmNicIpParams) SetIpaddress(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ipaddress"] = v - return -} - -func (p *UpdateVmNicIpParams) SetNicid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["nicid"] = v - return -} - -// You should always use this function to get a new UpdateVmNicIpParams instance, -// as then you are sure you have configured all required params -func (s *NicService) NewUpdateVmNicIpParams(nicid string) *UpdateVmNicIpParams { - p := &UpdateVmNicIpParams{} - p.p = make(map[string]interface{}) - p.p["nicid"] = nicid - return p -} - -// Update the default Ip of a VM Nic -func (s *NicService) UpdateVmNicIp(p *UpdateVmNicIpParams) (*UpdateVmNicIpResponse, error) { - resp, err := s.cs.newRequest("updateVmNicIp", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateVmNicIpResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateVmNicIpResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Affinitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Type string `json:"type,omitempty"` - VirtualmachineIds []string `json:"virtualmachineIds,omitempty"` - } `json:"affinitygroup,omitempty"` - Cpunumber int `json:"cpunumber,omitempty"` - Cpuspeed int `json:"cpuspeed,omitempty"` - Cpuused string `json:"cpuused,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Diskioread int64 `json:"diskioread,omitempty"` - Diskiowrite int64 `json:"diskiowrite,omitempty"` - Diskkbsread int64 `json:"diskkbsread,omitempty"` - Diskkbswrite int64 `json:"diskkbswrite,omitempty"` - Diskofferingid string `json:"diskofferingid,omitempty"` - Diskofferingname string `json:"diskofferingname,omitempty"` - Displayname string `json:"displayname,omitempty"` - Displayvm bool `json:"displayvm,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"` - Group string `json:"group,omitempty"` - Groupid string `json:"groupid,omitempty"` - Guestosid string `json:"guestosid,omitempty"` - Haenable bool `json:"haenable,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Instancename string `json:"instancename,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isodisplaytext string `json:"isodisplaytext,omitempty"` - Isoid string `json:"isoid,omitempty"` - Isoname string `json:"isoname,omitempty"` - Keypair string `json:"keypair,omitempty"` - Memory int `json:"memory,omitempty"` - Name string `json:"name,omitempty"` - Networkkbsread int64 `json:"networkkbsread,omitempty"` - Networkkbswrite int64 `json:"networkkbswrite,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Ostypeid int64 `json:"ostypeid,omitempty"` - Password string `json:"password,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - Rootdeviceid int64 `json:"rootdeviceid,omitempty"` - Rootdevicetype string `json:"rootdevicetype,omitempty"` - Securitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Egressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"egressrule,omitempty"` - Id string `json:"id,omitempty"` - Ingressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"ingressrule,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinecount int `json:"virtualmachinecount,omitempty"` - Virtualmachineids []string `json:"virtualmachineids,omitempty"` - } `json:"securitygroup,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - Servicestate string `json:"servicestate,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatedisplaytext string `json:"templatedisplaytext,omitempty"` - Templateid string `json:"templateid,omitempty"` - Templatename string `json:"templatename,omitempty"` - Userid string `json:"userid,omitempty"` - Username string `json:"username,omitempty"` - Vgpu string `json:"vgpu,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type ListNicsParams struct { - p map[string]interface{} -} - -func (p *ListNicsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["networkid"]; found { - u.Set("networkid", v.(string)) - } - if v, found := p.p["nicid"]; found { - u.Set("nicid", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["virtualmachineid"]; found { - u.Set("virtualmachineid", v.(string)) - } - return u -} - -func (p *ListNicsParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *ListNicsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListNicsParams) SetNetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkid"] = v - return -} - -func (p *ListNicsParams) SetNicid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["nicid"] = v - return -} - -func (p *ListNicsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListNicsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListNicsParams) SetVirtualmachineid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["virtualmachineid"] = v - return -} - -// You should always use this function to get a new ListNicsParams instance, -// as then you are sure you have configured all required params -func (s *NicService) NewListNicsParams(virtualmachineid string) *ListNicsParams { - p := &ListNicsParams{} - p.p = make(map[string]interface{}) - p.p["virtualmachineid"] = virtualmachineid - return p -} - -// list the vm nics IP to NIC -func (s *NicService) ListNics(p *ListNicsParams) (*ListNicsResponse, error) { - resp, err := s.cs.newRequest("listNics", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListNicsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListNicsResponse struct { - Count int `json:"count"` - Nics []*Nic `json:"nic"` -} - -type Nic struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/NiciraNVPService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/NiciraNVPService.go deleted file mode 100644 index 2efcd1587fd..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/NiciraNVPService.go +++ /dev/null @@ -1,332 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "net/url" - "strconv" -) - -type AddNiciraNvpDeviceParams struct { - p map[string]interface{} -} - -func (p *AddNiciraNvpDeviceParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["hostname"]; found { - u.Set("hostname", v.(string)) - } - if v, found := p.p["l3gatewayserviceuuid"]; found { - u.Set("l3gatewayserviceuuid", v.(string)) - } - if v, found := p.p["password"]; found { - u.Set("password", v.(string)) - } - if v, found := p.p["physicalnetworkid"]; found { - u.Set("physicalnetworkid", v.(string)) - } - if v, found := p.p["transportzoneuuid"]; found { - u.Set("transportzoneuuid", v.(string)) - } - if v, found := p.p["username"]; found { - u.Set("username", v.(string)) - } - return u -} - -func (p *AddNiciraNvpDeviceParams) SetHostname(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hostname"] = v - return -} - -func (p *AddNiciraNvpDeviceParams) SetL3gatewayserviceuuid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["l3gatewayserviceuuid"] = v - return -} - -func (p *AddNiciraNvpDeviceParams) SetPassword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["password"] = v - return -} - -func (p *AddNiciraNvpDeviceParams) SetPhysicalnetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["physicalnetworkid"] = v - return -} - -func (p *AddNiciraNvpDeviceParams) SetTransportzoneuuid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["transportzoneuuid"] = v - return -} - -func (p *AddNiciraNvpDeviceParams) SetUsername(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["username"] = v - return -} - -// You should always use this function to get a new AddNiciraNvpDeviceParams instance, -// as then you are sure you have configured all required params -func (s *NiciraNVPService) NewAddNiciraNvpDeviceParams(hostname string, password string, physicalnetworkid string, transportzoneuuid string, username string) *AddNiciraNvpDeviceParams { - p := &AddNiciraNvpDeviceParams{} - p.p = make(map[string]interface{}) - p.p["hostname"] = hostname - p.p["password"] = password - p.p["physicalnetworkid"] = physicalnetworkid - p.p["transportzoneuuid"] = transportzoneuuid - p.p["username"] = username - return p -} - -// Adds a Nicira NVP device -func (s *NiciraNVPService) AddNiciraNvpDevice(p *AddNiciraNvpDeviceParams) (*AddNiciraNvpDeviceResponse, error) { - resp, err := s.cs.newRequest("addNiciraNvpDevice", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AddNiciraNvpDeviceResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type AddNiciraNvpDeviceResponse struct { - JobID string `json:"jobid,omitempty"` - Hostname string `json:"hostname,omitempty"` - L3gatewayserviceuuid string `json:"l3gatewayserviceuuid,omitempty"` - Niciradevicename string `json:"niciradevicename,omitempty"` - Nvpdeviceid string `json:"nvpdeviceid,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Provider string `json:"provider,omitempty"` - Transportzoneuuid string `json:"transportzoneuuid,omitempty"` -} - -type DeleteNiciraNvpDeviceParams struct { - p map[string]interface{} -} - -func (p *DeleteNiciraNvpDeviceParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["nvpdeviceid"]; found { - u.Set("nvpdeviceid", v.(string)) - } - return u -} - -func (p *DeleteNiciraNvpDeviceParams) SetNvpdeviceid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["nvpdeviceid"] = v - return -} - -// You should always use this function to get a new DeleteNiciraNvpDeviceParams instance, -// as then you are sure you have configured all required params -func (s *NiciraNVPService) NewDeleteNiciraNvpDeviceParams(nvpdeviceid string) *DeleteNiciraNvpDeviceParams { - p := &DeleteNiciraNvpDeviceParams{} - p.p = make(map[string]interface{}) - p.p["nvpdeviceid"] = nvpdeviceid - return p -} - -// delete a nicira nvp device -func (s *NiciraNVPService) DeleteNiciraNvpDevice(p *DeleteNiciraNvpDeviceParams) (*DeleteNiciraNvpDeviceResponse, error) { - resp, err := s.cs.newRequest("deleteNiciraNvpDevice", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteNiciraNvpDeviceResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteNiciraNvpDeviceResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListNiciraNvpDevicesParams struct { - p map[string]interface{} -} - -func (p *ListNiciraNvpDevicesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["nvpdeviceid"]; found { - u.Set("nvpdeviceid", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["physicalnetworkid"]; found { - u.Set("physicalnetworkid", v.(string)) - } - return u -} - -func (p *ListNiciraNvpDevicesParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListNiciraNvpDevicesParams) SetNvpdeviceid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["nvpdeviceid"] = v - return -} - -func (p *ListNiciraNvpDevicesParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListNiciraNvpDevicesParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListNiciraNvpDevicesParams) SetPhysicalnetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["physicalnetworkid"] = v - return -} - -// You should always use this function to get a new ListNiciraNvpDevicesParams instance, -// as then you are sure you have configured all required params -func (s *NiciraNVPService) NewListNiciraNvpDevicesParams() *ListNiciraNvpDevicesParams { - p := &ListNiciraNvpDevicesParams{} - p.p = make(map[string]interface{}) - return p -} - -// Lists Nicira NVP devices -func (s *NiciraNVPService) ListNiciraNvpDevices(p *ListNiciraNvpDevicesParams) (*ListNiciraNvpDevicesResponse, error) { - resp, err := s.cs.newRequest("listNiciraNvpDevices", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListNiciraNvpDevicesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListNiciraNvpDevicesResponse struct { - Count int `json:"count"` - NiciraNvpDevices []*NiciraNvpDevice `json:"niciranvpdevice"` -} - -type NiciraNvpDevice struct { - Hostname string `json:"hostname,omitempty"` - L3gatewayserviceuuid string `json:"l3gatewayserviceuuid,omitempty"` - Niciradevicename string `json:"niciradevicename,omitempty"` - Nvpdeviceid string `json:"nvpdeviceid,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Provider string `json:"provider,omitempty"` - Transportzoneuuid string `json:"transportzoneuuid,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/OvsElementService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/OvsElementService.go deleted file mode 100644 index a86d61f2814..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/OvsElementService.go +++ /dev/null @@ -1,268 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type ConfigureOvsElementParams struct { - p map[string]interface{} -} - -func (p *ConfigureOvsElementParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["enabled"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("enabled", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *ConfigureOvsElementParams) SetEnabled(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["enabled"] = v - return -} - -func (p *ConfigureOvsElementParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new ConfigureOvsElementParams instance, -// as then you are sure you have configured all required params -func (s *OvsElementService) NewConfigureOvsElementParams(enabled bool, id string) *ConfigureOvsElementParams { - p := &ConfigureOvsElementParams{} - p.p = make(map[string]interface{}) - p.p["enabled"] = enabled - p.p["id"] = id - return p -} - -// Configures an ovs element. -func (s *OvsElementService) ConfigureOvsElement(p *ConfigureOvsElementParams) (*ConfigureOvsElementResponse, error) { - resp, err := s.cs.newRequest("configureOvsElement", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ConfigureOvsElementResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type ConfigureOvsElementResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Enabled bool `json:"enabled,omitempty"` - Id string `json:"id,omitempty"` - Nspid string `json:"nspid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` -} - -type ListOvsElementsParams struct { - p map[string]interface{} -} - -func (p *ListOvsElementsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["enabled"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("enabled", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["nspid"]; found { - u.Set("nspid", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - return u -} - -func (p *ListOvsElementsParams) SetEnabled(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["enabled"] = v - return -} - -func (p *ListOvsElementsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListOvsElementsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListOvsElementsParams) SetNspid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["nspid"] = v - return -} - -func (p *ListOvsElementsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListOvsElementsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -// You should always use this function to get a new ListOvsElementsParams instance, -// as then you are sure you have configured all required params -func (s *OvsElementService) NewListOvsElementsParams() *ListOvsElementsParams { - p := &ListOvsElementsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *OvsElementService) GetOvsElementByID(id string, opts ...OptionFunc) (*OvsElement, int, error) { - p := &ListOvsElementsParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListOvsElements(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.OvsElements[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for OvsElement UUID: %s!", id) -} - -// Lists all available ovs elements. -func (s *OvsElementService) ListOvsElements(p *ListOvsElementsParams) (*ListOvsElementsResponse, error) { - resp, err := s.cs.newRequest("listOvsElements", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListOvsElementsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListOvsElementsResponse struct { - Count int `json:"count"` - OvsElements []*OvsElement `json:"ovselement"` -} - -type OvsElement struct { - Account string `json:"account,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Enabled bool `json:"enabled,omitempty"` - Id string `json:"id,omitempty"` - Nspid string `json:"nspid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/PodService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/PodService.go deleted file mode 100644 index 2f0af1eecad..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/PodService.go +++ /dev/null @@ -1,882 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type CreatePodParams struct { - p map[string]interface{} -} - -func (p *CreatePodParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["allocationstate"]; found { - u.Set("allocationstate", v.(string)) - } - if v, found := p.p["endip"]; found { - u.Set("endip", v.(string)) - } - if v, found := p.p["gateway"]; found { - u.Set("gateway", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["netmask"]; found { - u.Set("netmask", v.(string)) - } - if v, found := p.p["startip"]; found { - u.Set("startip", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *CreatePodParams) SetAllocationstate(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["allocationstate"] = v - return -} - -func (p *CreatePodParams) SetEndip(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["endip"] = v - return -} - -func (p *CreatePodParams) SetGateway(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["gateway"] = v - return -} - -func (p *CreatePodParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *CreatePodParams) SetNetmask(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["netmask"] = v - return -} - -func (p *CreatePodParams) SetStartip(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["startip"] = v - return -} - -func (p *CreatePodParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new CreatePodParams instance, -// as then you are sure you have configured all required params -func (s *PodService) NewCreatePodParams(gateway string, name string, netmask string, startip string, zoneid string) *CreatePodParams { - p := &CreatePodParams{} - p.p = make(map[string]interface{}) - p.p["gateway"] = gateway - p.p["name"] = name - p.p["netmask"] = netmask - p.p["startip"] = startip - p.p["zoneid"] = zoneid - return p -} - -// Creates a new Pod. -func (s *PodService) CreatePod(p *CreatePodParams) (*CreatePodResponse, error) { - resp, err := s.cs.newRequest("createPod", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreatePodResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type CreatePodResponse struct { - Allocationstate string `json:"allocationstate,omitempty"` - Capacity []struct { - Capacitytotal int64 `json:"capacitytotal,omitempty"` - Capacityused int64 `json:"capacityused,omitempty"` - Clusterid string `json:"clusterid,omitempty"` - Clustername string `json:"clustername,omitempty"` - Percentused string `json:"percentused,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` - Type int `json:"type,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` - } `json:"capacity,omitempty"` - Endip string `json:"endip,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Netmask string `json:"netmask,omitempty"` - Startip string `json:"startip,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type UpdatePodParams struct { - p map[string]interface{} -} - -func (p *UpdatePodParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["allocationstate"]; found { - u.Set("allocationstate", v.(string)) - } - if v, found := p.p["endip"]; found { - u.Set("endip", v.(string)) - } - if v, found := p.p["gateway"]; found { - u.Set("gateway", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["netmask"]; found { - u.Set("netmask", v.(string)) - } - if v, found := p.p["startip"]; found { - u.Set("startip", v.(string)) - } - return u -} - -func (p *UpdatePodParams) SetAllocationstate(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["allocationstate"] = v - return -} - -func (p *UpdatePodParams) SetEndip(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["endip"] = v - return -} - -func (p *UpdatePodParams) SetGateway(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["gateway"] = v - return -} - -func (p *UpdatePodParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdatePodParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *UpdatePodParams) SetNetmask(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["netmask"] = v - return -} - -func (p *UpdatePodParams) SetStartip(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["startip"] = v - return -} - -// You should always use this function to get a new UpdatePodParams instance, -// as then you are sure you have configured all required params -func (s *PodService) NewUpdatePodParams(id string) *UpdatePodParams { - p := &UpdatePodParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates a Pod. -func (s *PodService) UpdatePod(p *UpdatePodParams) (*UpdatePodResponse, error) { - resp, err := s.cs.newRequest("updatePod", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdatePodResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type UpdatePodResponse struct { - Allocationstate string `json:"allocationstate,omitempty"` - Capacity []struct { - Capacitytotal int64 `json:"capacitytotal,omitempty"` - Capacityused int64 `json:"capacityused,omitempty"` - Clusterid string `json:"clusterid,omitempty"` - Clustername string `json:"clustername,omitempty"` - Percentused string `json:"percentused,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` - Type int `json:"type,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` - } `json:"capacity,omitempty"` - Endip string `json:"endip,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Netmask string `json:"netmask,omitempty"` - Startip string `json:"startip,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type DeletePodParams struct { - p map[string]interface{} -} - -func (p *DeletePodParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeletePodParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeletePodParams instance, -// as then you are sure you have configured all required params -func (s *PodService) NewDeletePodParams(id string) *DeletePodParams { - p := &DeletePodParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a Pod. -func (s *PodService) DeletePod(p *DeletePodParams) (*DeletePodResponse, error) { - resp, err := s.cs.newRequest("deletePod", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeletePodResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type DeletePodResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} - -type ListPodsParams struct { - p map[string]interface{} -} - -func (p *ListPodsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["allocationstate"]; found { - u.Set("allocationstate", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["showcapacities"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("showcapacities", vv) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ListPodsParams) SetAllocationstate(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["allocationstate"] = v - return -} - -func (p *ListPodsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListPodsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListPodsParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListPodsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListPodsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListPodsParams) SetShowcapacities(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["showcapacities"] = v - return -} - -func (p *ListPodsParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ListPodsParams instance, -// as then you are sure you have configured all required params -func (s *PodService) NewListPodsParams() *ListPodsParams { - p := &ListPodsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *PodService) GetPodID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListPodsParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListPods(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.Pods[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.Pods { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *PodService) GetPodByName(name string, opts ...OptionFunc) (*Pod, int, error) { - id, count, err := s.GetPodID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetPodByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *PodService) GetPodByID(id string, opts ...OptionFunc) (*Pod, int, error) { - p := &ListPodsParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListPods(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.Pods[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for Pod UUID: %s!", id) -} - -// Lists all Pods. -func (s *PodService) ListPods(p *ListPodsParams) (*ListPodsResponse, error) { - resp, err := s.cs.newRequest("listPods", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListPodsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListPodsResponse struct { - Count int `json:"count"` - Pods []*Pod `json:"pod"` -} - -type Pod struct { - Allocationstate string `json:"allocationstate,omitempty"` - Capacity []struct { - Capacitytotal int64 `json:"capacitytotal,omitempty"` - Capacityused int64 `json:"capacityused,omitempty"` - Clusterid string `json:"clusterid,omitempty"` - Clustername string `json:"clustername,omitempty"` - Percentused string `json:"percentused,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` - Type int `json:"type,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` - } `json:"capacity,omitempty"` - Endip string `json:"endip,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Netmask string `json:"netmask,omitempty"` - Startip string `json:"startip,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type DedicatePodParams struct { - p map[string]interface{} -} - -func (p *DedicatePodParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["podid"]; found { - u.Set("podid", v.(string)) - } - return u -} - -func (p *DedicatePodParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *DedicatePodParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *DedicatePodParams) SetPodid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["podid"] = v - return -} - -// You should always use this function to get a new DedicatePodParams instance, -// as then you are sure you have configured all required params -func (s *PodService) NewDedicatePodParams(domainid string, podid string) *DedicatePodParams { - p := &DedicatePodParams{} - p.p = make(map[string]interface{}) - p.p["domainid"] = domainid - p.p["podid"] = podid - return p -} - -// Dedicates a Pod. -func (s *PodService) DedicatePod(p *DedicatePodParams) (*DedicatePodResponse, error) { - resp, err := s.cs.newRequest("dedicatePod", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DedicatePodResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DedicatePodResponse struct { - JobID string `json:"jobid,omitempty"` - Accountid string `json:"accountid,omitempty"` - Affinitygroupid string `json:"affinitygroupid,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` -} - -type ReleaseDedicatedPodParams struct { - p map[string]interface{} -} - -func (p *ReleaseDedicatedPodParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["podid"]; found { - u.Set("podid", v.(string)) - } - return u -} - -func (p *ReleaseDedicatedPodParams) SetPodid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["podid"] = v - return -} - -// You should always use this function to get a new ReleaseDedicatedPodParams instance, -// as then you are sure you have configured all required params -func (s *PodService) NewReleaseDedicatedPodParams(podid string) *ReleaseDedicatedPodParams { - p := &ReleaseDedicatedPodParams{} - p.p = make(map[string]interface{}) - p.p["podid"] = podid - return p -} - -// Release the dedication for the pod -func (s *PodService) ReleaseDedicatedPod(p *ReleaseDedicatedPodParams) (*ReleaseDedicatedPodResponse, error) { - resp, err := s.cs.newRequest("releaseDedicatedPod", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ReleaseDedicatedPodResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type ReleaseDedicatedPodResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListDedicatedPodsParams struct { - p map[string]interface{} -} - -func (p *ListDedicatedPodsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["affinitygroupid"]; found { - u.Set("affinitygroupid", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["podid"]; found { - u.Set("podid", v.(string)) - } - return u -} - -func (p *ListDedicatedPodsParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListDedicatedPodsParams) SetAffinitygroupid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["affinitygroupid"] = v - return -} - -func (p *ListDedicatedPodsParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListDedicatedPodsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListDedicatedPodsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListDedicatedPodsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListDedicatedPodsParams) SetPodid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["podid"] = v - return -} - -// You should always use this function to get a new ListDedicatedPodsParams instance, -// as then you are sure you have configured all required params -func (s *PodService) NewListDedicatedPodsParams() *ListDedicatedPodsParams { - p := &ListDedicatedPodsParams{} - p.p = make(map[string]interface{}) - return p -} - -// Lists dedicated pods. -func (s *PodService) ListDedicatedPods(p *ListDedicatedPodsParams) (*ListDedicatedPodsResponse, error) { - resp, err := s.cs.newRequest("listDedicatedPods", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListDedicatedPodsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListDedicatedPodsResponse struct { - Count int `json:"count"` - DedicatedPods []*DedicatedPod `json:"dedicatedpod"` -} - -type DedicatedPod struct { - Accountid string `json:"accountid,omitempty"` - Affinitygroupid string `json:"affinitygroupid,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/PoolService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/PoolService.go deleted file mode 100644 index f2f8fce990f..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/PoolService.go +++ /dev/null @@ -1,800 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type ListStoragePoolsParams struct { - p map[string]interface{} -} - -func (p *ListStoragePoolsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["clusterid"]; found { - u.Set("clusterid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["ipaddress"]; found { - u.Set("ipaddress", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["path"]; found { - u.Set("path", v.(string)) - } - if v, found := p.p["podid"]; found { - u.Set("podid", v.(string)) - } - if v, found := p.p["scope"]; found { - u.Set("scope", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ListStoragePoolsParams) SetClusterid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["clusterid"] = v - return -} - -func (p *ListStoragePoolsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListStoragePoolsParams) SetIpaddress(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ipaddress"] = v - return -} - -func (p *ListStoragePoolsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListStoragePoolsParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListStoragePoolsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListStoragePoolsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListStoragePoolsParams) SetPath(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["path"] = v - return -} - -func (p *ListStoragePoolsParams) SetPodid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["podid"] = v - return -} - -func (p *ListStoragePoolsParams) SetScope(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["scope"] = v - return -} - -func (p *ListStoragePoolsParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ListStoragePoolsParams instance, -// as then you are sure you have configured all required params -func (s *PoolService) NewListStoragePoolsParams() *ListStoragePoolsParams { - p := &ListStoragePoolsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *PoolService) GetStoragePoolID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListStoragePoolsParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListStoragePools(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.StoragePools[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.StoragePools { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *PoolService) GetStoragePoolByName(name string, opts ...OptionFunc) (*StoragePool, int, error) { - id, count, err := s.GetStoragePoolID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetStoragePoolByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *PoolService) GetStoragePoolByID(id string, opts ...OptionFunc) (*StoragePool, int, error) { - p := &ListStoragePoolsParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListStoragePools(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.StoragePools[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for StoragePool UUID: %s!", id) -} - -// Lists storage pools. -func (s *PoolService) ListStoragePools(p *ListStoragePoolsParams) (*ListStoragePoolsResponse, error) { - resp, err := s.cs.newRequest("listStoragePools", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListStoragePoolsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListStoragePoolsResponse struct { - Count int `json:"count"` - StoragePools []*StoragePool `json:"storagepool"` -} - -type StoragePool struct { - Capacityiops int64 `json:"capacityiops,omitempty"` - Clusterid string `json:"clusterid,omitempty"` - Clustername string `json:"clustername,omitempty"` - Created string `json:"created,omitempty"` - Disksizeallocated int64 `json:"disksizeallocated,omitempty"` - Disksizetotal int64 `json:"disksizetotal,omitempty"` - Disksizeused int64 `json:"disksizeused,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Name string `json:"name,omitempty"` - Overprovisionfactor string `json:"overprovisionfactor,omitempty"` - Path string `json:"path,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` - Scope string `json:"scope,omitempty"` - State string `json:"state,omitempty"` - Storagecapabilities map[string]string `json:"storagecapabilities,omitempty"` - Suitableformigration bool `json:"suitableformigration,omitempty"` - Tags string `json:"tags,omitempty"` - Type string `json:"type,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type CreateStoragePoolParams struct { - p map[string]interface{} -} - -func (p *CreateStoragePoolParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["capacitybytes"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("capacitybytes", vv) - } - if v, found := p.p["capacityiops"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("capacityiops", vv) - } - if v, found := p.p["clusterid"]; found { - u.Set("clusterid", v.(string)) - } - if v, found := p.p["details"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("details[%d].key", i), k) - u.Set(fmt.Sprintf("details[%d].value", i), vv) - i++ - } - } - if v, found := p.p["hypervisor"]; found { - u.Set("hypervisor", v.(string)) - } - if v, found := p.p["managed"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("managed", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["podid"]; found { - u.Set("podid", v.(string)) - } - if v, found := p.p["provider"]; found { - u.Set("provider", v.(string)) - } - if v, found := p.p["scope"]; found { - u.Set("scope", v.(string)) - } - if v, found := p.p["tags"]; found { - u.Set("tags", v.(string)) - } - if v, found := p.p["url"]; found { - u.Set("url", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *CreateStoragePoolParams) SetCapacitybytes(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["capacitybytes"] = v - return -} - -func (p *CreateStoragePoolParams) SetCapacityiops(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["capacityiops"] = v - return -} - -func (p *CreateStoragePoolParams) SetClusterid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["clusterid"] = v - return -} - -func (p *CreateStoragePoolParams) SetDetails(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["details"] = v - return -} - -func (p *CreateStoragePoolParams) SetHypervisor(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hypervisor"] = v - return -} - -func (p *CreateStoragePoolParams) SetManaged(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["managed"] = v - return -} - -func (p *CreateStoragePoolParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *CreateStoragePoolParams) SetPodid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["podid"] = v - return -} - -func (p *CreateStoragePoolParams) SetProvider(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["provider"] = v - return -} - -func (p *CreateStoragePoolParams) SetScope(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["scope"] = v - return -} - -func (p *CreateStoragePoolParams) SetTags(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tags"] = v - return -} - -func (p *CreateStoragePoolParams) SetUrl(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["url"] = v - return -} - -func (p *CreateStoragePoolParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new CreateStoragePoolParams instance, -// as then you are sure you have configured all required params -func (s *PoolService) NewCreateStoragePoolParams(name string, url string, zoneid string) *CreateStoragePoolParams { - p := &CreateStoragePoolParams{} - p.p = make(map[string]interface{}) - p.p["name"] = name - p.p["url"] = url - p.p["zoneid"] = zoneid - return p -} - -// Creates a storage pool. -func (s *PoolService) CreateStoragePool(p *CreateStoragePoolParams) (*CreateStoragePoolResponse, error) { - resp, err := s.cs.newRequest("createStoragePool", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateStoragePoolResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type CreateStoragePoolResponse struct { - Capacityiops int64 `json:"capacityiops,omitempty"` - Clusterid string `json:"clusterid,omitempty"` - Clustername string `json:"clustername,omitempty"` - Created string `json:"created,omitempty"` - Disksizeallocated int64 `json:"disksizeallocated,omitempty"` - Disksizetotal int64 `json:"disksizetotal,omitempty"` - Disksizeused int64 `json:"disksizeused,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Name string `json:"name,omitempty"` - Overprovisionfactor string `json:"overprovisionfactor,omitempty"` - Path string `json:"path,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` - Scope string `json:"scope,omitempty"` - State string `json:"state,omitempty"` - Storagecapabilities map[string]string `json:"storagecapabilities,omitempty"` - Suitableformigration bool `json:"suitableformigration,omitempty"` - Tags string `json:"tags,omitempty"` - Type string `json:"type,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type UpdateStoragePoolParams struct { - p map[string]interface{} -} - -func (p *UpdateStoragePoolParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["capacitybytes"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("capacitybytes", vv) - } - if v, found := p.p["capacityiops"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("capacityiops", vv) - } - if v, found := p.p["enabled"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("enabled", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["tags"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("tags", vv) - } - return u -} - -func (p *UpdateStoragePoolParams) SetCapacitybytes(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["capacitybytes"] = v - return -} - -func (p *UpdateStoragePoolParams) SetCapacityiops(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["capacityiops"] = v - return -} - -func (p *UpdateStoragePoolParams) SetEnabled(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["enabled"] = v - return -} - -func (p *UpdateStoragePoolParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateStoragePoolParams) SetTags(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tags"] = v - return -} - -// You should always use this function to get a new UpdateStoragePoolParams instance, -// as then you are sure you have configured all required params -func (s *PoolService) NewUpdateStoragePoolParams(id string) *UpdateStoragePoolParams { - p := &UpdateStoragePoolParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates a storage pool. -func (s *PoolService) UpdateStoragePool(p *UpdateStoragePoolParams) (*UpdateStoragePoolResponse, error) { - resp, err := s.cs.newRequest("updateStoragePool", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateStoragePoolResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type UpdateStoragePoolResponse struct { - Capacityiops int64 `json:"capacityiops,omitempty"` - Clusterid string `json:"clusterid,omitempty"` - Clustername string `json:"clustername,omitempty"` - Created string `json:"created,omitempty"` - Disksizeallocated int64 `json:"disksizeallocated,omitempty"` - Disksizetotal int64 `json:"disksizetotal,omitempty"` - Disksizeused int64 `json:"disksizeused,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Name string `json:"name,omitempty"` - Overprovisionfactor string `json:"overprovisionfactor,omitempty"` - Path string `json:"path,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` - Scope string `json:"scope,omitempty"` - State string `json:"state,omitempty"` - Storagecapabilities map[string]string `json:"storagecapabilities,omitempty"` - Suitableformigration bool `json:"suitableformigration,omitempty"` - Tags string `json:"tags,omitempty"` - Type string `json:"type,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type DeleteStoragePoolParams struct { - p map[string]interface{} -} - -func (p *DeleteStoragePoolParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["forced"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("forced", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteStoragePoolParams) SetForced(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["forced"] = v - return -} - -func (p *DeleteStoragePoolParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteStoragePoolParams instance, -// as then you are sure you have configured all required params -func (s *PoolService) NewDeleteStoragePoolParams(id string) *DeleteStoragePoolParams { - p := &DeleteStoragePoolParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a storage pool. -func (s *PoolService) DeleteStoragePool(p *DeleteStoragePoolParams) (*DeleteStoragePoolResponse, error) { - resp, err := s.cs.newRequest("deleteStoragePool", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteStoragePoolResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type DeleteStoragePoolResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} - -type FindStoragePoolsForMigrationParams struct { - p map[string]interface{} -} - -func (p *FindStoragePoolsForMigrationParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - return u -} - -func (p *FindStoragePoolsForMigrationParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *FindStoragePoolsForMigrationParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *FindStoragePoolsForMigrationParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *FindStoragePoolsForMigrationParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -// You should always use this function to get a new FindStoragePoolsForMigrationParams instance, -// as then you are sure you have configured all required params -func (s *PoolService) NewFindStoragePoolsForMigrationParams(id string) *FindStoragePoolsForMigrationParams { - p := &FindStoragePoolsForMigrationParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Lists storage pools available for migration of a volume. -func (s *PoolService) FindStoragePoolsForMigration(p *FindStoragePoolsForMigrationParams) (*FindStoragePoolsForMigrationResponse, error) { - resp, err := s.cs.newRequest("findStoragePoolsForMigration", p.toURLValues()) - if err != nil { - return nil, err - } - - var r FindStoragePoolsForMigrationResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type FindStoragePoolsForMigrationResponse struct { - Capacityiops int64 `json:"capacityiops,omitempty"` - Clusterid string `json:"clusterid,omitempty"` - Clustername string `json:"clustername,omitempty"` - Created string `json:"created,omitempty"` - Disksizeallocated int64 `json:"disksizeallocated,omitempty"` - Disksizetotal int64 `json:"disksizetotal,omitempty"` - Disksizeused int64 `json:"disksizeused,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Name string `json:"name,omitempty"` - Overprovisionfactor string `json:"overprovisionfactor,omitempty"` - Path string `json:"path,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` - Scope string `json:"scope,omitempty"` - State string `json:"state,omitempty"` - Storagecapabilities map[string]string `json:"storagecapabilities,omitempty"` - Suitableformigration bool `json:"suitableformigration,omitempty"` - Tags string `json:"tags,omitempty"` - Type string `json:"type,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/PortableIPService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/PortableIPService.go deleted file mode 100644 index 2896ae2bb3f..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/PortableIPService.go +++ /dev/null @@ -1,393 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type CreatePortableIpRangeParams struct { - p map[string]interface{} -} - -func (p *CreatePortableIpRangeParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["endip"]; found { - u.Set("endip", v.(string)) - } - if v, found := p.p["gateway"]; found { - u.Set("gateway", v.(string)) - } - if v, found := p.p["netmask"]; found { - u.Set("netmask", v.(string)) - } - if v, found := p.p["regionid"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("regionid", vv) - } - if v, found := p.p["startip"]; found { - u.Set("startip", v.(string)) - } - if v, found := p.p["vlan"]; found { - u.Set("vlan", v.(string)) - } - return u -} - -func (p *CreatePortableIpRangeParams) SetEndip(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["endip"] = v - return -} - -func (p *CreatePortableIpRangeParams) SetGateway(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["gateway"] = v - return -} - -func (p *CreatePortableIpRangeParams) SetNetmask(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["netmask"] = v - return -} - -func (p *CreatePortableIpRangeParams) SetRegionid(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["regionid"] = v - return -} - -func (p *CreatePortableIpRangeParams) SetStartip(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["startip"] = v - return -} - -func (p *CreatePortableIpRangeParams) SetVlan(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vlan"] = v - return -} - -// You should always use this function to get a new CreatePortableIpRangeParams instance, -// as then you are sure you have configured all required params -func (s *PortableIPService) NewCreatePortableIpRangeParams(endip string, gateway string, netmask string, regionid int, startip string) *CreatePortableIpRangeParams { - p := &CreatePortableIpRangeParams{} - p.p = make(map[string]interface{}) - p.p["endip"] = endip - p.p["gateway"] = gateway - p.p["netmask"] = netmask - p.p["regionid"] = regionid - p.p["startip"] = startip - return p -} - -// adds a range of portable public IP's to a region -func (s *PortableIPService) CreatePortableIpRange(p *CreatePortableIpRangeParams) (*CreatePortableIpRangeResponse, error) { - resp, err := s.cs.newRequest("createPortableIpRange", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreatePortableIpRangeResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreatePortableIpRangeResponse struct { - JobID string `json:"jobid,omitempty"` - Endip string `json:"endip,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Netmask string `json:"netmask,omitempty"` - Portableipaddress []struct { - Accountid string `json:"accountid,omitempty"` - Allocated string `json:"allocated,omitempty"` - Domainid string `json:"domainid,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Networkid string `json:"networkid,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Regionid int `json:"regionid,omitempty"` - State string `json:"state,omitempty"` - Vpcid string `json:"vpcid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - } `json:"portableipaddress,omitempty"` - Regionid int `json:"regionid,omitempty"` - Startip string `json:"startip,omitempty"` - Vlan string `json:"vlan,omitempty"` -} - -type DeletePortableIpRangeParams struct { - p map[string]interface{} -} - -func (p *DeletePortableIpRangeParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeletePortableIpRangeParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeletePortableIpRangeParams instance, -// as then you are sure you have configured all required params -func (s *PortableIPService) NewDeletePortableIpRangeParams(id string) *DeletePortableIpRangeParams { - p := &DeletePortableIpRangeParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// deletes a range of portable public IP's associated with a region -func (s *PortableIPService) DeletePortableIpRange(p *DeletePortableIpRangeParams) (*DeletePortableIpRangeResponse, error) { - resp, err := s.cs.newRequest("deletePortableIpRange", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeletePortableIpRangeResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeletePortableIpRangeResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListPortableIpRangesParams struct { - p map[string]interface{} -} - -func (p *ListPortableIpRangesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["regionid"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("regionid", vv) - } - return u -} - -func (p *ListPortableIpRangesParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListPortableIpRangesParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListPortableIpRangesParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListPortableIpRangesParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListPortableIpRangesParams) SetRegionid(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["regionid"] = v - return -} - -// You should always use this function to get a new ListPortableIpRangesParams instance, -// as then you are sure you have configured all required params -func (s *PortableIPService) NewListPortableIpRangesParams() *ListPortableIpRangesParams { - p := &ListPortableIpRangesParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *PortableIPService) GetPortableIpRangeByID(id string, opts ...OptionFunc) (*PortableIpRange, int, error) { - p := &ListPortableIpRangesParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListPortableIpRanges(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.PortableIpRanges[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for PortableIpRange UUID: %s!", id) -} - -// list portable IP ranges -func (s *PortableIPService) ListPortableIpRanges(p *ListPortableIpRangesParams) (*ListPortableIpRangesResponse, error) { - resp, err := s.cs.newRequest("listPortableIpRanges", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListPortableIpRangesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListPortableIpRangesResponse struct { - Count int `json:"count"` - PortableIpRanges []*PortableIpRange `json:"portableiprange"` -} - -type PortableIpRange struct { - Endip string `json:"endip,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Netmask string `json:"netmask,omitempty"` - Portableipaddress []struct { - Accountid string `json:"accountid,omitempty"` - Allocated string `json:"allocated,omitempty"` - Domainid string `json:"domainid,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Networkid string `json:"networkid,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Regionid int `json:"regionid,omitempty"` - State string `json:"state,omitempty"` - Vpcid string `json:"vpcid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - } `json:"portableipaddress,omitempty"` - Regionid int `json:"regionid,omitempty"` - Startip string `json:"startip,omitempty"` - Vlan string `json:"vlan,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/ProjectService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/ProjectService.go deleted file mode 100644 index 8b9c0e86f0c..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/ProjectService.go +++ /dev/null @@ -1,1341 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type CreateProjectParams struct { - p map[string]interface{} -} - -func (p *CreateProjectParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["displaytext"]; found { - u.Set("displaytext", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - return u -} - -func (p *CreateProjectParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *CreateProjectParams) SetDisplaytext(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displaytext"] = v - return -} - -func (p *CreateProjectParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *CreateProjectParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -// You should always use this function to get a new CreateProjectParams instance, -// as then you are sure you have configured all required params -func (s *ProjectService) NewCreateProjectParams(displaytext string, name string) *CreateProjectParams { - p := &CreateProjectParams{} - p.p = make(map[string]interface{}) - p.p["displaytext"] = displaytext - p.p["name"] = name - return p -} - -// Creates a project -func (s *ProjectService) CreateProject(p *CreateProjectParams) (*CreateProjectResponse, error) { - resp, err := s.cs.newRequest("createProject", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateProjectResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateProjectResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Cpuavailable string `json:"cpuavailable,omitempty"` - Cpulimit string `json:"cpulimit,omitempty"` - Cputotal int64 `json:"cputotal,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Ipavailable string `json:"ipavailable,omitempty"` - Iplimit string `json:"iplimit,omitempty"` - Iptotal int64 `json:"iptotal,omitempty"` - Memoryavailable string `json:"memoryavailable,omitempty"` - Memorylimit string `json:"memorylimit,omitempty"` - Memorytotal int64 `json:"memorytotal,omitempty"` - Name string `json:"name,omitempty"` - Networkavailable string `json:"networkavailable,omitempty"` - Networklimit string `json:"networklimit,omitempty"` - Networktotal int64 `json:"networktotal,omitempty"` - Primarystorageavailable string `json:"primarystorageavailable,omitempty"` - Primarystoragelimit string `json:"primarystoragelimit,omitempty"` - Primarystoragetotal int64 `json:"primarystoragetotal,omitempty"` - Secondarystorageavailable string `json:"secondarystorageavailable,omitempty"` - Secondarystoragelimit string `json:"secondarystoragelimit,omitempty"` - Secondarystoragetotal int64 `json:"secondarystoragetotal,omitempty"` - Snapshotavailable string `json:"snapshotavailable,omitempty"` - Snapshotlimit string `json:"snapshotlimit,omitempty"` - Snapshottotal int64 `json:"snapshottotal,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templateavailable string `json:"templateavailable,omitempty"` - Templatelimit string `json:"templatelimit,omitempty"` - Templatetotal int64 `json:"templatetotal,omitempty"` - Vmavailable string `json:"vmavailable,omitempty"` - Vmlimit string `json:"vmlimit,omitempty"` - Vmrunning int `json:"vmrunning,omitempty"` - Vmstopped int `json:"vmstopped,omitempty"` - Vmtotal int64 `json:"vmtotal,omitempty"` - Volumeavailable string `json:"volumeavailable,omitempty"` - Volumelimit string `json:"volumelimit,omitempty"` - Volumetotal int64 `json:"volumetotal,omitempty"` - Vpcavailable string `json:"vpcavailable,omitempty"` - Vpclimit string `json:"vpclimit,omitempty"` - Vpctotal int64 `json:"vpctotal,omitempty"` -} - -type DeleteProjectParams struct { - p map[string]interface{} -} - -func (p *DeleteProjectParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteProjectParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteProjectParams instance, -// as then you are sure you have configured all required params -func (s *ProjectService) NewDeleteProjectParams(id string) *DeleteProjectParams { - p := &DeleteProjectParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a project -func (s *ProjectService) DeleteProject(p *DeleteProjectParams) (*DeleteProjectResponse, error) { - resp, err := s.cs.newRequest("deleteProject", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteProjectResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteProjectResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type UpdateProjectParams struct { - p map[string]interface{} -} - -func (p *UpdateProjectParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["displaytext"]; found { - u.Set("displaytext", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *UpdateProjectParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *UpdateProjectParams) SetDisplaytext(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displaytext"] = v - return -} - -func (p *UpdateProjectParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new UpdateProjectParams instance, -// as then you are sure you have configured all required params -func (s *ProjectService) NewUpdateProjectParams(id string) *UpdateProjectParams { - p := &UpdateProjectParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates a project -func (s *ProjectService) UpdateProject(p *UpdateProjectParams) (*UpdateProjectResponse, error) { - resp, err := s.cs.newRequest("updateProject", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateProjectResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateProjectResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Cpuavailable string `json:"cpuavailable,omitempty"` - Cpulimit string `json:"cpulimit,omitempty"` - Cputotal int64 `json:"cputotal,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Ipavailable string `json:"ipavailable,omitempty"` - Iplimit string `json:"iplimit,omitempty"` - Iptotal int64 `json:"iptotal,omitempty"` - Memoryavailable string `json:"memoryavailable,omitempty"` - Memorylimit string `json:"memorylimit,omitempty"` - Memorytotal int64 `json:"memorytotal,omitempty"` - Name string `json:"name,omitempty"` - Networkavailable string `json:"networkavailable,omitempty"` - Networklimit string `json:"networklimit,omitempty"` - Networktotal int64 `json:"networktotal,omitempty"` - Primarystorageavailable string `json:"primarystorageavailable,omitempty"` - Primarystoragelimit string `json:"primarystoragelimit,omitempty"` - Primarystoragetotal int64 `json:"primarystoragetotal,omitempty"` - Secondarystorageavailable string `json:"secondarystorageavailable,omitempty"` - Secondarystoragelimit string `json:"secondarystoragelimit,omitempty"` - Secondarystoragetotal int64 `json:"secondarystoragetotal,omitempty"` - Snapshotavailable string `json:"snapshotavailable,omitempty"` - Snapshotlimit string `json:"snapshotlimit,omitempty"` - Snapshottotal int64 `json:"snapshottotal,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templateavailable string `json:"templateavailable,omitempty"` - Templatelimit string `json:"templatelimit,omitempty"` - Templatetotal int64 `json:"templatetotal,omitempty"` - Vmavailable string `json:"vmavailable,omitempty"` - Vmlimit string `json:"vmlimit,omitempty"` - Vmrunning int `json:"vmrunning,omitempty"` - Vmstopped int `json:"vmstopped,omitempty"` - Vmtotal int64 `json:"vmtotal,omitempty"` - Volumeavailable string `json:"volumeavailable,omitempty"` - Volumelimit string `json:"volumelimit,omitempty"` - Volumetotal int64 `json:"volumetotal,omitempty"` - Vpcavailable string `json:"vpcavailable,omitempty"` - Vpclimit string `json:"vpclimit,omitempty"` - Vpctotal int64 `json:"vpctotal,omitempty"` -} - -type ActivateProjectParams struct { - p map[string]interface{} -} - -func (p *ActivateProjectParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *ActivateProjectParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new ActivateProjectParams instance, -// as then you are sure you have configured all required params -func (s *ProjectService) NewActivateProjectParams(id string) *ActivateProjectParams { - p := &ActivateProjectParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Activates a project -func (s *ProjectService) ActivateProject(p *ActivateProjectParams) (*ActivateProjectResponse, error) { - resp, err := s.cs.newRequest("activateProject", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ActivateProjectResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type ActivateProjectResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Cpuavailable string `json:"cpuavailable,omitempty"` - Cpulimit string `json:"cpulimit,omitempty"` - Cputotal int64 `json:"cputotal,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Ipavailable string `json:"ipavailable,omitempty"` - Iplimit string `json:"iplimit,omitempty"` - Iptotal int64 `json:"iptotal,omitempty"` - Memoryavailable string `json:"memoryavailable,omitempty"` - Memorylimit string `json:"memorylimit,omitempty"` - Memorytotal int64 `json:"memorytotal,omitempty"` - Name string `json:"name,omitempty"` - Networkavailable string `json:"networkavailable,omitempty"` - Networklimit string `json:"networklimit,omitempty"` - Networktotal int64 `json:"networktotal,omitempty"` - Primarystorageavailable string `json:"primarystorageavailable,omitempty"` - Primarystoragelimit string `json:"primarystoragelimit,omitempty"` - Primarystoragetotal int64 `json:"primarystoragetotal,omitempty"` - Secondarystorageavailable string `json:"secondarystorageavailable,omitempty"` - Secondarystoragelimit string `json:"secondarystoragelimit,omitempty"` - Secondarystoragetotal int64 `json:"secondarystoragetotal,omitempty"` - Snapshotavailable string `json:"snapshotavailable,omitempty"` - Snapshotlimit string `json:"snapshotlimit,omitempty"` - Snapshottotal int64 `json:"snapshottotal,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templateavailable string `json:"templateavailable,omitempty"` - Templatelimit string `json:"templatelimit,omitempty"` - Templatetotal int64 `json:"templatetotal,omitempty"` - Vmavailable string `json:"vmavailable,omitempty"` - Vmlimit string `json:"vmlimit,omitempty"` - Vmrunning int `json:"vmrunning,omitempty"` - Vmstopped int `json:"vmstopped,omitempty"` - Vmtotal int64 `json:"vmtotal,omitempty"` - Volumeavailable string `json:"volumeavailable,omitempty"` - Volumelimit string `json:"volumelimit,omitempty"` - Volumetotal int64 `json:"volumetotal,omitempty"` - Vpcavailable string `json:"vpcavailable,omitempty"` - Vpclimit string `json:"vpclimit,omitempty"` - Vpctotal int64 `json:"vpctotal,omitempty"` -} - -type SuspendProjectParams struct { - p map[string]interface{} -} - -func (p *SuspendProjectParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *SuspendProjectParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new SuspendProjectParams instance, -// as then you are sure you have configured all required params -func (s *ProjectService) NewSuspendProjectParams(id string) *SuspendProjectParams { - p := &SuspendProjectParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Suspends a project -func (s *ProjectService) SuspendProject(p *SuspendProjectParams) (*SuspendProjectResponse, error) { - resp, err := s.cs.newRequest("suspendProject", p.toURLValues()) - if err != nil { - return nil, err - } - - var r SuspendProjectResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type SuspendProjectResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Cpuavailable string `json:"cpuavailable,omitempty"` - Cpulimit string `json:"cpulimit,omitempty"` - Cputotal int64 `json:"cputotal,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Ipavailable string `json:"ipavailable,omitempty"` - Iplimit string `json:"iplimit,omitempty"` - Iptotal int64 `json:"iptotal,omitempty"` - Memoryavailable string `json:"memoryavailable,omitempty"` - Memorylimit string `json:"memorylimit,omitempty"` - Memorytotal int64 `json:"memorytotal,omitempty"` - Name string `json:"name,omitempty"` - Networkavailable string `json:"networkavailable,omitempty"` - Networklimit string `json:"networklimit,omitempty"` - Networktotal int64 `json:"networktotal,omitempty"` - Primarystorageavailable string `json:"primarystorageavailable,omitempty"` - Primarystoragelimit string `json:"primarystoragelimit,omitempty"` - Primarystoragetotal int64 `json:"primarystoragetotal,omitempty"` - Secondarystorageavailable string `json:"secondarystorageavailable,omitempty"` - Secondarystoragelimit string `json:"secondarystoragelimit,omitempty"` - Secondarystoragetotal int64 `json:"secondarystoragetotal,omitempty"` - Snapshotavailable string `json:"snapshotavailable,omitempty"` - Snapshotlimit string `json:"snapshotlimit,omitempty"` - Snapshottotal int64 `json:"snapshottotal,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templateavailable string `json:"templateavailable,omitempty"` - Templatelimit string `json:"templatelimit,omitempty"` - Templatetotal int64 `json:"templatetotal,omitempty"` - Vmavailable string `json:"vmavailable,omitempty"` - Vmlimit string `json:"vmlimit,omitempty"` - Vmrunning int `json:"vmrunning,omitempty"` - Vmstopped int `json:"vmstopped,omitempty"` - Vmtotal int64 `json:"vmtotal,omitempty"` - Volumeavailable string `json:"volumeavailable,omitempty"` - Volumelimit string `json:"volumelimit,omitempty"` - Volumetotal int64 `json:"volumetotal,omitempty"` - Vpcavailable string `json:"vpcavailable,omitempty"` - Vpclimit string `json:"vpclimit,omitempty"` - Vpctotal int64 `json:"vpctotal,omitempty"` -} - -type ListProjectsParams struct { - p map[string]interface{} -} - -func (p *ListProjectsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["displaytext"]; found { - u.Set("displaytext", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["state"]; found { - u.Set("state", v.(string)) - } - if v, found := p.p["tags"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("tags[%d].key", i), k) - u.Set(fmt.Sprintf("tags[%d].value", i), vv) - i++ - } - } - return u -} - -func (p *ListProjectsParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListProjectsParams) SetDisplaytext(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displaytext"] = v - return -} - -func (p *ListProjectsParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListProjectsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListProjectsParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListProjectsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListProjectsParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListProjectsParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListProjectsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListProjectsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListProjectsParams) SetState(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["state"] = v - return -} - -func (p *ListProjectsParams) SetTags(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tags"] = v - return -} - -// You should always use this function to get a new ListProjectsParams instance, -// as then you are sure you have configured all required params -func (s *ProjectService) NewListProjectsParams() *ListProjectsParams { - p := &ListProjectsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *ProjectService) GetProjectID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListProjectsParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListProjects(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.Projects[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.Projects { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *ProjectService) GetProjectByName(name string, opts ...OptionFunc) (*Project, int, error) { - id, count, err := s.GetProjectID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetProjectByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *ProjectService) GetProjectByID(id string, opts ...OptionFunc) (*Project, int, error) { - p := &ListProjectsParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListProjects(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.Projects[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for Project UUID: %s!", id) -} - -// Lists projects and provides detailed information for listed projects -func (s *ProjectService) ListProjects(p *ListProjectsParams) (*ListProjectsResponse, error) { - resp, err := s.cs.newRequest("listProjects", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListProjectsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListProjectsResponse struct { - Count int `json:"count"` - Projects []*Project `json:"project"` -} - -type Project struct { - Account string `json:"account,omitempty"` - Cpuavailable string `json:"cpuavailable,omitempty"` - Cpulimit string `json:"cpulimit,omitempty"` - Cputotal int64 `json:"cputotal,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Ipavailable string `json:"ipavailable,omitempty"` - Iplimit string `json:"iplimit,omitempty"` - Iptotal int64 `json:"iptotal,omitempty"` - Memoryavailable string `json:"memoryavailable,omitempty"` - Memorylimit string `json:"memorylimit,omitempty"` - Memorytotal int64 `json:"memorytotal,omitempty"` - Name string `json:"name,omitempty"` - Networkavailable string `json:"networkavailable,omitempty"` - Networklimit string `json:"networklimit,omitempty"` - Networktotal int64 `json:"networktotal,omitempty"` - Primarystorageavailable string `json:"primarystorageavailable,omitempty"` - Primarystoragelimit string `json:"primarystoragelimit,omitempty"` - Primarystoragetotal int64 `json:"primarystoragetotal,omitempty"` - Secondarystorageavailable string `json:"secondarystorageavailable,omitempty"` - Secondarystoragelimit string `json:"secondarystoragelimit,omitempty"` - Secondarystoragetotal int64 `json:"secondarystoragetotal,omitempty"` - Snapshotavailable string `json:"snapshotavailable,omitempty"` - Snapshotlimit string `json:"snapshotlimit,omitempty"` - Snapshottotal int64 `json:"snapshottotal,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templateavailable string `json:"templateavailable,omitempty"` - Templatelimit string `json:"templatelimit,omitempty"` - Templatetotal int64 `json:"templatetotal,omitempty"` - Vmavailable string `json:"vmavailable,omitempty"` - Vmlimit string `json:"vmlimit,omitempty"` - Vmrunning int `json:"vmrunning,omitempty"` - Vmstopped int `json:"vmstopped,omitempty"` - Vmtotal int64 `json:"vmtotal,omitempty"` - Volumeavailable string `json:"volumeavailable,omitempty"` - Volumelimit string `json:"volumelimit,omitempty"` - Volumetotal int64 `json:"volumetotal,omitempty"` - Vpcavailable string `json:"vpcavailable,omitempty"` - Vpclimit string `json:"vpclimit,omitempty"` - Vpctotal int64 `json:"vpctotal,omitempty"` -} - -type ListProjectInvitationsParams struct { - p map[string]interface{} -} - -func (p *ListProjectInvitationsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["activeonly"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("activeonly", vv) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["state"]; found { - u.Set("state", v.(string)) - } - return u -} - -func (p *ListProjectInvitationsParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListProjectInvitationsParams) SetActiveonly(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["activeonly"] = v - return -} - -func (p *ListProjectInvitationsParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListProjectInvitationsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListProjectInvitationsParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListProjectInvitationsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListProjectInvitationsParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListProjectInvitationsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListProjectInvitationsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListProjectInvitationsParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListProjectInvitationsParams) SetState(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["state"] = v - return -} - -// You should always use this function to get a new ListProjectInvitationsParams instance, -// as then you are sure you have configured all required params -func (s *ProjectService) NewListProjectInvitationsParams() *ListProjectInvitationsParams { - p := &ListProjectInvitationsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *ProjectService) GetProjectInvitationByID(id string, opts ...OptionFunc) (*ProjectInvitation, int, error) { - p := &ListProjectInvitationsParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListProjectInvitations(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.ProjectInvitations[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for ProjectInvitation UUID: %s!", id) -} - -// Lists project invitations and provides detailed information for listed invitations -func (s *ProjectService) ListProjectInvitations(p *ListProjectInvitationsParams) (*ListProjectInvitationsResponse, error) { - resp, err := s.cs.newRequest("listProjectInvitations", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListProjectInvitationsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListProjectInvitationsResponse struct { - Count int `json:"count"` - ProjectInvitations []*ProjectInvitation `json:"projectinvitation"` -} - -type ProjectInvitation struct { - Account string `json:"account,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Email string `json:"email,omitempty"` - Id string `json:"id,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - State string `json:"state,omitempty"` -} - -type UpdateProjectInvitationParams struct { - p map[string]interface{} -} - -func (p *UpdateProjectInvitationParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["accept"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("accept", vv) - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["token"]; found { - u.Set("token", v.(string)) - } - return u -} - -func (p *UpdateProjectInvitationParams) SetAccept(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["accept"] = v - return -} - -func (p *UpdateProjectInvitationParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *UpdateProjectInvitationParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *UpdateProjectInvitationParams) SetToken(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["token"] = v - return -} - -// You should always use this function to get a new UpdateProjectInvitationParams instance, -// as then you are sure you have configured all required params -func (s *ProjectService) NewUpdateProjectInvitationParams(projectid string) *UpdateProjectInvitationParams { - p := &UpdateProjectInvitationParams{} - p.p = make(map[string]interface{}) - p.p["projectid"] = projectid - return p -} - -// Accepts or declines project invitation -func (s *ProjectService) UpdateProjectInvitation(p *UpdateProjectInvitationParams) (*UpdateProjectInvitationResponse, error) { - resp, err := s.cs.newRequest("updateProjectInvitation", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateProjectInvitationResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateProjectInvitationResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type DeleteProjectInvitationParams struct { - p map[string]interface{} -} - -func (p *DeleteProjectInvitationParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteProjectInvitationParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteProjectInvitationParams instance, -// as then you are sure you have configured all required params -func (s *ProjectService) NewDeleteProjectInvitationParams(id string) *DeleteProjectInvitationParams { - p := &DeleteProjectInvitationParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes project invitation -func (s *ProjectService) DeleteProjectInvitation(p *DeleteProjectInvitationParams) (*DeleteProjectInvitationResponse, error) { - resp, err := s.cs.newRequest("deleteProjectInvitation", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteProjectInvitationResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteProjectInvitationResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/QuotaService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/QuotaService.go deleted file mode 100644 index 896a4d79838..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/QuotaService.go +++ /dev/null @@ -1,60 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "net/url" -) - -type QuotaIsEnabledParams struct { - p map[string]interface{} -} - -func (p *QuotaIsEnabledParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - return u -} - -// You should always use this function to get a new QuotaIsEnabledParams instance, -// as then you are sure you have configured all required params -func (s *QuotaService) NewQuotaIsEnabledParams() *QuotaIsEnabledParams { - p := &QuotaIsEnabledParams{} - p.p = make(map[string]interface{}) - return p -} - -// Return true if the plugin is enabled -func (s *QuotaService) QuotaIsEnabled(p *QuotaIsEnabledParams) (*QuotaIsEnabledResponse, error) { - resp, err := s.cs.newRequest("quotaIsEnabled", p.toURLValues()) - if err != nil { - return nil, err - } - - var r QuotaIsEnabledResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type QuotaIsEnabledResponse struct { - Isenabled bool `json:"isenabled,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/RegionService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/RegionService.go deleted file mode 100644 index a434f851361..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/RegionService.go +++ /dev/null @@ -1,336 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "net/url" - "strconv" -) - -type AddRegionParams struct { - p map[string]interface{} -} - -func (p *AddRegionParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["endpoint"]; found { - u.Set("endpoint", v.(string)) - } - if v, found := p.p["id"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("id", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - return u -} - -func (p *AddRegionParams) SetEndpoint(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["endpoint"] = v - return -} - -func (p *AddRegionParams) SetId(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *AddRegionParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -// You should always use this function to get a new AddRegionParams instance, -// as then you are sure you have configured all required params -func (s *RegionService) NewAddRegionParams(endpoint string, id int, name string) *AddRegionParams { - p := &AddRegionParams{} - p.p = make(map[string]interface{}) - p.p["endpoint"] = endpoint - p.p["id"] = id - p.p["name"] = name - return p -} - -// Adds a Region -func (s *RegionService) AddRegion(p *AddRegionParams) (*AddRegionResponse, error) { - resp, err := s.cs.newRequest("addRegion", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AddRegionResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type AddRegionResponse struct { - Endpoint string `json:"endpoint,omitempty"` - Gslbserviceenabled bool `json:"gslbserviceenabled,omitempty"` - Id int `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Portableipserviceenabled bool `json:"portableipserviceenabled,omitempty"` -} - -type UpdateRegionParams struct { - p map[string]interface{} -} - -func (p *UpdateRegionParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["endpoint"]; found { - u.Set("endpoint", v.(string)) - } - if v, found := p.p["id"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("id", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - return u -} - -func (p *UpdateRegionParams) SetEndpoint(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["endpoint"] = v - return -} - -func (p *UpdateRegionParams) SetId(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateRegionParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -// You should always use this function to get a new UpdateRegionParams instance, -// as then you are sure you have configured all required params -func (s *RegionService) NewUpdateRegionParams(id int) *UpdateRegionParams { - p := &UpdateRegionParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates a region -func (s *RegionService) UpdateRegion(p *UpdateRegionParams) (*UpdateRegionResponse, error) { - resp, err := s.cs.newRequest("updateRegion", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateRegionResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type UpdateRegionResponse struct { - Endpoint string `json:"endpoint,omitempty"` - Gslbserviceenabled bool `json:"gslbserviceenabled,omitempty"` - Id int `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Portableipserviceenabled bool `json:"portableipserviceenabled,omitempty"` -} - -type RemoveRegionParams struct { - p map[string]interface{} -} - -func (p *RemoveRegionParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("id", vv) - } - return u -} - -func (p *RemoveRegionParams) SetId(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new RemoveRegionParams instance, -// as then you are sure you have configured all required params -func (s *RegionService) NewRemoveRegionParams(id int) *RemoveRegionParams { - p := &RemoveRegionParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Removes specified region -func (s *RegionService) RemoveRegion(p *RemoveRegionParams) (*RemoveRegionResponse, error) { - resp, err := s.cs.newRequest("removeRegion", p.toURLValues()) - if err != nil { - return nil, err - } - - var r RemoveRegionResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type RemoveRegionResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} - -type ListRegionsParams struct { - p map[string]interface{} -} - -func (p *ListRegionsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("id", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - return u -} - -func (p *ListRegionsParams) SetId(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListRegionsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListRegionsParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListRegionsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListRegionsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -// You should always use this function to get a new ListRegionsParams instance, -// as then you are sure you have configured all required params -func (s *RegionService) NewListRegionsParams() *ListRegionsParams { - p := &ListRegionsParams{} - p.p = make(map[string]interface{}) - return p -} - -// Lists Regions -func (s *RegionService) ListRegions(p *ListRegionsParams) (*ListRegionsResponse, error) { - resp, err := s.cs.newRequest("listRegions", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListRegionsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListRegionsResponse struct { - Count int `json:"count"` - Regions []*Region `json:"region"` -} - -type Region struct { - Endpoint string `json:"endpoint,omitempty"` - Gslbserviceenabled bool `json:"gslbserviceenabled,omitempty"` - Id int `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Portableipserviceenabled bool `json:"portableipserviceenabled,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/ResourcemetadataService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/ResourcemetadataService.go deleted file mode 100644 index 136b9d3b177..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/ResourcemetadataService.go +++ /dev/null @@ -1,423 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" -) - -type AddResourceDetailParams struct { - p map[string]interface{} -} - -func (p *AddResourceDetailParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["details"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("details[%d].key", i), k) - u.Set(fmt.Sprintf("details[%d].value", i), vv) - i++ - } - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["resourceid"]; found { - u.Set("resourceid", v.(string)) - } - if v, found := p.p["resourcetype"]; found { - u.Set("resourcetype", v.(string)) - } - return u -} - -func (p *AddResourceDetailParams) SetDetails(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["details"] = v - return -} - -func (p *AddResourceDetailParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *AddResourceDetailParams) SetResourceid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["resourceid"] = v - return -} - -func (p *AddResourceDetailParams) SetResourcetype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["resourcetype"] = v - return -} - -// You should always use this function to get a new AddResourceDetailParams instance, -// as then you are sure you have configured all required params -func (s *ResourcemetadataService) NewAddResourceDetailParams(details map[string]string, resourceid string, resourcetype string) *AddResourceDetailParams { - p := &AddResourceDetailParams{} - p.p = make(map[string]interface{}) - p.p["details"] = details - p.p["resourceid"] = resourceid - p.p["resourcetype"] = resourcetype - return p -} - -// Adds detail for the Resource. -func (s *ResourcemetadataService) AddResourceDetail(p *AddResourceDetailParams) (*AddResourceDetailResponse, error) { - resp, err := s.cs.newRequest("addResourceDetail", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AddResourceDetailResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type AddResourceDetailResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type RemoveResourceDetailParams struct { - p map[string]interface{} -} - -func (p *RemoveResourceDetailParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["key"]; found { - u.Set("key", v.(string)) - } - if v, found := p.p["resourceid"]; found { - u.Set("resourceid", v.(string)) - } - if v, found := p.p["resourcetype"]; found { - u.Set("resourcetype", v.(string)) - } - return u -} - -func (p *RemoveResourceDetailParams) SetKey(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["key"] = v - return -} - -func (p *RemoveResourceDetailParams) SetResourceid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["resourceid"] = v - return -} - -func (p *RemoveResourceDetailParams) SetResourcetype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["resourcetype"] = v - return -} - -// You should always use this function to get a new RemoveResourceDetailParams instance, -// as then you are sure you have configured all required params -func (s *ResourcemetadataService) NewRemoveResourceDetailParams(resourceid string, resourcetype string) *RemoveResourceDetailParams { - p := &RemoveResourceDetailParams{} - p.p = make(map[string]interface{}) - p.p["resourceid"] = resourceid - p.p["resourcetype"] = resourcetype - return p -} - -// Removes detail for the Resource. -func (s *ResourcemetadataService) RemoveResourceDetail(p *RemoveResourceDetailParams) (*RemoveResourceDetailResponse, error) { - resp, err := s.cs.newRequest("removeResourceDetail", p.toURLValues()) - if err != nil { - return nil, err - } - - var r RemoveResourceDetailResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type RemoveResourceDetailResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListResourceDetailsParams struct { - p map[string]interface{} -} - -func (p *ListResourceDetailsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["key"]; found { - u.Set("key", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["resourceid"]; found { - u.Set("resourceid", v.(string)) - } - if v, found := p.p["resourcetype"]; found { - u.Set("resourcetype", v.(string)) - } - if v, found := p.p["value"]; found { - u.Set("value", v.(string)) - } - return u -} - -func (p *ListResourceDetailsParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListResourceDetailsParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListResourceDetailsParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *ListResourceDetailsParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListResourceDetailsParams) SetKey(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["key"] = v - return -} - -func (p *ListResourceDetailsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListResourceDetailsParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListResourceDetailsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListResourceDetailsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListResourceDetailsParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListResourceDetailsParams) SetResourceid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["resourceid"] = v - return -} - -func (p *ListResourceDetailsParams) SetResourcetype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["resourcetype"] = v - return -} - -func (p *ListResourceDetailsParams) SetValue(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["value"] = v - return -} - -// You should always use this function to get a new ListResourceDetailsParams instance, -// as then you are sure you have configured all required params -func (s *ResourcemetadataService) NewListResourceDetailsParams(resourcetype string) *ListResourceDetailsParams { - p := &ListResourceDetailsParams{} - p.p = make(map[string]interface{}) - p.p["resourcetype"] = resourcetype - return p -} - -// List resource detail(s) -func (s *ResourcemetadataService) ListResourceDetails(p *ListResourceDetailsParams) (*ListResourceDetailsResponse, error) { - resp, err := s.cs.newRequest("listResourceDetails", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListResourceDetailsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListResourceDetailsResponse struct { - Count int `json:"count"` - ResourceDetails []*ResourceDetail `json:"resourcedetail"` -} - -type ResourceDetail struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/ResourcetagsService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/ResourcetagsService.go deleted file mode 100644 index b285a2466f6..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/ResourcetagsService.go +++ /dev/null @@ -1,544 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type ListStorageTagsParams struct { - p map[string]interface{} -} - -func (p *ListStorageTagsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - return u -} - -func (p *ListStorageTagsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListStorageTagsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListStorageTagsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -// You should always use this function to get a new ListStorageTagsParams instance, -// as then you are sure you have configured all required params -func (s *ResourcetagsService) NewListStorageTagsParams() *ListStorageTagsParams { - p := &ListStorageTagsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *ResourcetagsService) GetStorageTagID(keyword string, opts ...OptionFunc) (string, int, error) { - p := &ListStorageTagsParams{} - p.p = make(map[string]interface{}) - - p.p["keyword"] = keyword - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListStorageTags(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", keyword, l) - } - - if l.Count == 1 { - return l.StorageTags[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.StorageTags { - if v.Name == keyword { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l) -} - -// Lists storage tags -func (s *ResourcetagsService) ListStorageTags(p *ListStorageTagsParams) (*ListStorageTagsResponse, error) { - resp, err := s.cs.newRequest("listStorageTags", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListStorageTagsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListStorageTagsResponse struct { - Count int `json:"count"` - StorageTags []*StorageTag `json:"storagetag"` -} - -type StorageTag struct { - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Poolid int64 `json:"poolid,omitempty"` -} - -type CreateTagsParams struct { - p map[string]interface{} -} - -func (p *CreateTagsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["customer"]; found { - u.Set("customer", v.(string)) - } - if v, found := p.p["resourceids"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("resourceids", vv) - } - if v, found := p.p["resourcetype"]; found { - u.Set("resourcetype", v.(string)) - } - if v, found := p.p["tags"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("tags[%d].key", i), k) - u.Set(fmt.Sprintf("tags[%d].value", i), vv) - i++ - } - } - return u -} - -func (p *CreateTagsParams) SetCustomer(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["customer"] = v - return -} - -func (p *CreateTagsParams) SetResourceids(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["resourceids"] = v - return -} - -func (p *CreateTagsParams) SetResourcetype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["resourcetype"] = v - return -} - -func (p *CreateTagsParams) SetTags(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tags"] = v - return -} - -// You should always use this function to get a new CreateTagsParams instance, -// as then you are sure you have configured all required params -func (s *ResourcetagsService) NewCreateTagsParams(resourceids []string, resourcetype string, tags map[string]string) *CreateTagsParams { - p := &CreateTagsParams{} - p.p = make(map[string]interface{}) - p.p["resourceids"] = resourceids - p.p["resourcetype"] = resourcetype - p.p["tags"] = tags - return p -} - -// Creates resource tag(s) -func (s *ResourcetagsService) CreateTags(p *CreateTagsParams) (*CreateTagsResponse, error) { - resp, err := s.cs.newRequest("createTags", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateTagsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateTagsResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type DeleteTagsParams struct { - p map[string]interface{} -} - -func (p *DeleteTagsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["resourceids"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("resourceids", vv) - } - if v, found := p.p["resourcetype"]; found { - u.Set("resourcetype", v.(string)) - } - if v, found := p.p["tags"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("tags[%d].key", i), k) - u.Set(fmt.Sprintf("tags[%d].value", i), vv) - i++ - } - } - return u -} - -func (p *DeleteTagsParams) SetResourceids(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["resourceids"] = v - return -} - -func (p *DeleteTagsParams) SetResourcetype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["resourcetype"] = v - return -} - -func (p *DeleteTagsParams) SetTags(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tags"] = v - return -} - -// You should always use this function to get a new DeleteTagsParams instance, -// as then you are sure you have configured all required params -func (s *ResourcetagsService) NewDeleteTagsParams(resourceids []string, resourcetype string) *DeleteTagsParams { - p := &DeleteTagsParams{} - p.p = make(map[string]interface{}) - p.p["resourceids"] = resourceids - p.p["resourcetype"] = resourcetype - return p -} - -// Deleting resource tag(s) -func (s *ResourcetagsService) DeleteTags(p *DeleteTagsParams) (*DeleteTagsResponse, error) { - resp, err := s.cs.newRequest("deleteTags", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteTagsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteTagsResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListTagsParams struct { - p map[string]interface{} -} - -func (p *ListTagsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["customer"]; found { - u.Set("customer", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["key"]; found { - u.Set("key", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["resourceid"]; found { - u.Set("resourceid", v.(string)) - } - if v, found := p.p["resourcetype"]; found { - u.Set("resourcetype", v.(string)) - } - if v, found := p.p["value"]; found { - u.Set("value", v.(string)) - } - return u -} - -func (p *ListTagsParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListTagsParams) SetCustomer(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["customer"] = v - return -} - -func (p *ListTagsParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListTagsParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListTagsParams) SetKey(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["key"] = v - return -} - -func (p *ListTagsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListTagsParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListTagsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListTagsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListTagsParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListTagsParams) SetResourceid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["resourceid"] = v - return -} - -func (p *ListTagsParams) SetResourcetype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["resourcetype"] = v - return -} - -func (p *ListTagsParams) SetValue(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["value"] = v - return -} - -// You should always use this function to get a new ListTagsParams instance, -// as then you are sure you have configured all required params -func (s *ResourcetagsService) NewListTagsParams() *ListTagsParams { - p := &ListTagsParams{} - p.p = make(map[string]interface{}) - return p -} - -// List resource tag(s) -func (s *ResourcetagsService) ListTags(p *ListTagsParams) (*ListTagsResponse, error) { - resp, err := s.cs.newRequest("listTags", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListTagsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListTagsResponse struct { - Count int `json:"count"` - Tags []*Tag `json:"tag"` -} - -type Tag struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/RouterService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/RouterService.go deleted file mode 100644 index 05496b53033..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/RouterService.go +++ /dev/null @@ -1,1457 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type StartRouterParams struct { - p map[string]interface{} -} - -func (p *StartRouterParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *StartRouterParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new StartRouterParams instance, -// as then you are sure you have configured all required params -func (s *RouterService) NewStartRouterParams(id string) *StartRouterParams { - p := &StartRouterParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Starts a router. -func (s *RouterService) StartRouter(p *StartRouterParams) (*StartRouterResponse, error) { - resp, err := s.cs.newRequest("startRouter", p.toURLValues()) - if err != nil { - return nil, err - } - - var r StartRouterResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type StartRouterResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Created string `json:"created,omitempty"` - Dns1 string `json:"dns1,omitempty"` - Dns2 string `json:"dns2,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Guestipaddress string `json:"guestipaddress,omitempty"` - Guestmacaddress string `json:"guestmacaddress,omitempty"` - Guestnetmask string `json:"guestnetmask,omitempty"` - Guestnetworkid string `json:"guestnetworkid,omitempty"` - Guestnetworkname string `json:"guestnetworkname,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Ip6dns1 string `json:"ip6dns1,omitempty"` - Ip6dns2 string `json:"ip6dns2,omitempty"` - Isredundantrouter bool `json:"isredundantrouter,omitempty"` - Linklocalip string `json:"linklocalip,omitempty"` - Linklocalmacaddress string `json:"linklocalmacaddress,omitempty"` - Linklocalnetmask string `json:"linklocalnetmask,omitempty"` - Linklocalnetworkid string `json:"linklocalnetworkid,omitempty"` - Name string `json:"name,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Podid string `json:"podid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicmacaddress string `json:"publicmacaddress,omitempty"` - Publicnetmask string `json:"publicnetmask,omitempty"` - Publicnetworkid string `json:"publicnetworkid,omitempty"` - Redundantstate string `json:"redundantstate,omitempty"` - Requiresupgrade bool `json:"requiresupgrade,omitempty"` - Role string `json:"role,omitempty"` - Scriptsversion string `json:"scriptsversion,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - State string `json:"state,omitempty"` - Templateid string `json:"templateid,omitempty"` - Version string `json:"version,omitempty"` - Vpcid string `json:"vpcid,omitempty"` - Vpcname string `json:"vpcname,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type RebootRouterParams struct { - p map[string]interface{} -} - -func (p *RebootRouterParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *RebootRouterParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new RebootRouterParams instance, -// as then you are sure you have configured all required params -func (s *RouterService) NewRebootRouterParams(id string) *RebootRouterParams { - p := &RebootRouterParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Starts a router. -func (s *RouterService) RebootRouter(p *RebootRouterParams) (*RebootRouterResponse, error) { - resp, err := s.cs.newRequest("rebootRouter", p.toURLValues()) - if err != nil { - return nil, err - } - - var r RebootRouterResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type RebootRouterResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Created string `json:"created,omitempty"` - Dns1 string `json:"dns1,omitempty"` - Dns2 string `json:"dns2,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Guestipaddress string `json:"guestipaddress,omitempty"` - Guestmacaddress string `json:"guestmacaddress,omitempty"` - Guestnetmask string `json:"guestnetmask,omitempty"` - Guestnetworkid string `json:"guestnetworkid,omitempty"` - Guestnetworkname string `json:"guestnetworkname,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Ip6dns1 string `json:"ip6dns1,omitempty"` - Ip6dns2 string `json:"ip6dns2,omitempty"` - Isredundantrouter bool `json:"isredundantrouter,omitempty"` - Linklocalip string `json:"linklocalip,omitempty"` - Linklocalmacaddress string `json:"linklocalmacaddress,omitempty"` - Linklocalnetmask string `json:"linklocalnetmask,omitempty"` - Linklocalnetworkid string `json:"linklocalnetworkid,omitempty"` - Name string `json:"name,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Podid string `json:"podid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicmacaddress string `json:"publicmacaddress,omitempty"` - Publicnetmask string `json:"publicnetmask,omitempty"` - Publicnetworkid string `json:"publicnetworkid,omitempty"` - Redundantstate string `json:"redundantstate,omitempty"` - Requiresupgrade bool `json:"requiresupgrade,omitempty"` - Role string `json:"role,omitempty"` - Scriptsversion string `json:"scriptsversion,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - State string `json:"state,omitempty"` - Templateid string `json:"templateid,omitempty"` - Version string `json:"version,omitempty"` - Vpcid string `json:"vpcid,omitempty"` - Vpcname string `json:"vpcname,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type StopRouterParams struct { - p map[string]interface{} -} - -func (p *StopRouterParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["forced"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("forced", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *StopRouterParams) SetForced(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["forced"] = v - return -} - -func (p *StopRouterParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new StopRouterParams instance, -// as then you are sure you have configured all required params -func (s *RouterService) NewStopRouterParams(id string) *StopRouterParams { - p := &StopRouterParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Stops a router. -func (s *RouterService) StopRouter(p *StopRouterParams) (*StopRouterResponse, error) { - resp, err := s.cs.newRequest("stopRouter", p.toURLValues()) - if err != nil { - return nil, err - } - - var r StopRouterResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type StopRouterResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Created string `json:"created,omitempty"` - Dns1 string `json:"dns1,omitempty"` - Dns2 string `json:"dns2,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Guestipaddress string `json:"guestipaddress,omitempty"` - Guestmacaddress string `json:"guestmacaddress,omitempty"` - Guestnetmask string `json:"guestnetmask,omitempty"` - Guestnetworkid string `json:"guestnetworkid,omitempty"` - Guestnetworkname string `json:"guestnetworkname,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Ip6dns1 string `json:"ip6dns1,omitempty"` - Ip6dns2 string `json:"ip6dns2,omitempty"` - Isredundantrouter bool `json:"isredundantrouter,omitempty"` - Linklocalip string `json:"linklocalip,omitempty"` - Linklocalmacaddress string `json:"linklocalmacaddress,omitempty"` - Linklocalnetmask string `json:"linklocalnetmask,omitempty"` - Linklocalnetworkid string `json:"linklocalnetworkid,omitempty"` - Name string `json:"name,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Podid string `json:"podid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicmacaddress string `json:"publicmacaddress,omitempty"` - Publicnetmask string `json:"publicnetmask,omitempty"` - Publicnetworkid string `json:"publicnetworkid,omitempty"` - Redundantstate string `json:"redundantstate,omitempty"` - Requiresupgrade bool `json:"requiresupgrade,omitempty"` - Role string `json:"role,omitempty"` - Scriptsversion string `json:"scriptsversion,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - State string `json:"state,omitempty"` - Templateid string `json:"templateid,omitempty"` - Version string `json:"version,omitempty"` - Vpcid string `json:"vpcid,omitempty"` - Vpcname string `json:"vpcname,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type DestroyRouterParams struct { - p map[string]interface{} -} - -func (p *DestroyRouterParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DestroyRouterParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DestroyRouterParams instance, -// as then you are sure you have configured all required params -func (s *RouterService) NewDestroyRouterParams(id string) *DestroyRouterParams { - p := &DestroyRouterParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Destroys a router. -func (s *RouterService) DestroyRouter(p *DestroyRouterParams) (*DestroyRouterResponse, error) { - resp, err := s.cs.newRequest("destroyRouter", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DestroyRouterResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DestroyRouterResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Created string `json:"created,omitempty"` - Dns1 string `json:"dns1,omitempty"` - Dns2 string `json:"dns2,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Guestipaddress string `json:"guestipaddress,omitempty"` - Guestmacaddress string `json:"guestmacaddress,omitempty"` - Guestnetmask string `json:"guestnetmask,omitempty"` - Guestnetworkid string `json:"guestnetworkid,omitempty"` - Guestnetworkname string `json:"guestnetworkname,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Ip6dns1 string `json:"ip6dns1,omitempty"` - Ip6dns2 string `json:"ip6dns2,omitempty"` - Isredundantrouter bool `json:"isredundantrouter,omitempty"` - Linklocalip string `json:"linklocalip,omitempty"` - Linklocalmacaddress string `json:"linklocalmacaddress,omitempty"` - Linklocalnetmask string `json:"linklocalnetmask,omitempty"` - Linklocalnetworkid string `json:"linklocalnetworkid,omitempty"` - Name string `json:"name,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Podid string `json:"podid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicmacaddress string `json:"publicmacaddress,omitempty"` - Publicnetmask string `json:"publicnetmask,omitempty"` - Publicnetworkid string `json:"publicnetworkid,omitempty"` - Redundantstate string `json:"redundantstate,omitempty"` - Requiresupgrade bool `json:"requiresupgrade,omitempty"` - Role string `json:"role,omitempty"` - Scriptsversion string `json:"scriptsversion,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - State string `json:"state,omitempty"` - Templateid string `json:"templateid,omitempty"` - Version string `json:"version,omitempty"` - Vpcid string `json:"vpcid,omitempty"` - Vpcname string `json:"vpcname,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type ChangeServiceForRouterParams struct { - p map[string]interface{} -} - -func (p *ChangeServiceForRouterParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["serviceofferingid"]; found { - u.Set("serviceofferingid", v.(string)) - } - return u -} - -func (p *ChangeServiceForRouterParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ChangeServiceForRouterParams) SetServiceofferingid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["serviceofferingid"] = v - return -} - -// You should always use this function to get a new ChangeServiceForRouterParams instance, -// as then you are sure you have configured all required params -func (s *RouterService) NewChangeServiceForRouterParams(id string, serviceofferingid string) *ChangeServiceForRouterParams { - p := &ChangeServiceForRouterParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - p.p["serviceofferingid"] = serviceofferingid - return p -} - -// Upgrades domain router to a new service offering -func (s *RouterService) ChangeServiceForRouter(p *ChangeServiceForRouterParams) (*ChangeServiceForRouterResponse, error) { - resp, err := s.cs.newRequest("changeServiceForRouter", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ChangeServiceForRouterResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ChangeServiceForRouterResponse struct { - Account string `json:"account,omitempty"` - Created string `json:"created,omitempty"` - Dns1 string `json:"dns1,omitempty"` - Dns2 string `json:"dns2,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Guestipaddress string `json:"guestipaddress,omitempty"` - Guestmacaddress string `json:"guestmacaddress,omitempty"` - Guestnetmask string `json:"guestnetmask,omitempty"` - Guestnetworkid string `json:"guestnetworkid,omitempty"` - Guestnetworkname string `json:"guestnetworkname,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Ip6dns1 string `json:"ip6dns1,omitempty"` - Ip6dns2 string `json:"ip6dns2,omitempty"` - Isredundantrouter bool `json:"isredundantrouter,omitempty"` - Linklocalip string `json:"linklocalip,omitempty"` - Linklocalmacaddress string `json:"linklocalmacaddress,omitempty"` - Linklocalnetmask string `json:"linklocalnetmask,omitempty"` - Linklocalnetworkid string `json:"linklocalnetworkid,omitempty"` - Name string `json:"name,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Podid string `json:"podid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicmacaddress string `json:"publicmacaddress,omitempty"` - Publicnetmask string `json:"publicnetmask,omitempty"` - Publicnetworkid string `json:"publicnetworkid,omitempty"` - Redundantstate string `json:"redundantstate,omitempty"` - Requiresupgrade bool `json:"requiresupgrade,omitempty"` - Role string `json:"role,omitempty"` - Scriptsversion string `json:"scriptsversion,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - State string `json:"state,omitempty"` - Templateid string `json:"templateid,omitempty"` - Version string `json:"version,omitempty"` - Vpcid string `json:"vpcid,omitempty"` - Vpcname string `json:"vpcname,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type ListRoutersParams struct { - p map[string]interface{} -} - -func (p *ListRoutersParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["clusterid"]; found { - u.Set("clusterid", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["forvpc"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("forvpc", vv) - } - if v, found := p.p["hostid"]; found { - u.Set("hostid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["networkid"]; found { - u.Set("networkid", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["podid"]; found { - u.Set("podid", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["state"]; found { - u.Set("state", v.(string)) - } - if v, found := p.p["version"]; found { - u.Set("version", v.(string)) - } - if v, found := p.p["vpcid"]; found { - u.Set("vpcid", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ListRoutersParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListRoutersParams) SetClusterid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["clusterid"] = v - return -} - -func (p *ListRoutersParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListRoutersParams) SetForvpc(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["forvpc"] = v - return -} - -func (p *ListRoutersParams) SetHostid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hostid"] = v - return -} - -func (p *ListRoutersParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListRoutersParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListRoutersParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListRoutersParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListRoutersParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListRoutersParams) SetNetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkid"] = v - return -} - -func (p *ListRoutersParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListRoutersParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListRoutersParams) SetPodid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["podid"] = v - return -} - -func (p *ListRoutersParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListRoutersParams) SetState(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["state"] = v - return -} - -func (p *ListRoutersParams) SetVersion(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["version"] = v - return -} - -func (p *ListRoutersParams) SetVpcid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vpcid"] = v - return -} - -func (p *ListRoutersParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ListRoutersParams instance, -// as then you are sure you have configured all required params -func (s *RouterService) NewListRoutersParams() *ListRoutersParams { - p := &ListRoutersParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *RouterService) GetRouterID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListRoutersParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListRouters(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.Routers[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.Routers { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *RouterService) GetRouterByName(name string, opts ...OptionFunc) (*Router, int, error) { - id, count, err := s.GetRouterID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetRouterByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *RouterService) GetRouterByID(id string, opts ...OptionFunc) (*Router, int, error) { - p := &ListRoutersParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListRouters(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.Routers[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for Router UUID: %s!", id) -} - -// List routers. -func (s *RouterService) ListRouters(p *ListRoutersParams) (*ListRoutersResponse, error) { - resp, err := s.cs.newRequest("listRouters", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListRoutersResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListRoutersResponse struct { - Count int `json:"count"` - Routers []*Router `json:"router"` -} - -type Router struct { - Account string `json:"account,omitempty"` - Created string `json:"created,omitempty"` - Dns1 string `json:"dns1,omitempty"` - Dns2 string `json:"dns2,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Guestipaddress string `json:"guestipaddress,omitempty"` - Guestmacaddress string `json:"guestmacaddress,omitempty"` - Guestnetmask string `json:"guestnetmask,omitempty"` - Guestnetworkid string `json:"guestnetworkid,omitempty"` - Guestnetworkname string `json:"guestnetworkname,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Ip6dns1 string `json:"ip6dns1,omitempty"` - Ip6dns2 string `json:"ip6dns2,omitempty"` - Isredundantrouter bool `json:"isredundantrouter,omitempty"` - Linklocalip string `json:"linklocalip,omitempty"` - Linklocalmacaddress string `json:"linklocalmacaddress,omitempty"` - Linklocalnetmask string `json:"linklocalnetmask,omitempty"` - Linklocalnetworkid string `json:"linklocalnetworkid,omitempty"` - Name string `json:"name,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Podid string `json:"podid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicmacaddress string `json:"publicmacaddress,omitempty"` - Publicnetmask string `json:"publicnetmask,omitempty"` - Publicnetworkid string `json:"publicnetworkid,omitempty"` - Redundantstate string `json:"redundantstate,omitempty"` - Requiresupgrade bool `json:"requiresupgrade,omitempty"` - Role string `json:"role,omitempty"` - Scriptsversion string `json:"scriptsversion,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - State string `json:"state,omitempty"` - Templateid string `json:"templateid,omitempty"` - Version string `json:"version,omitempty"` - Vpcid string `json:"vpcid,omitempty"` - Vpcname string `json:"vpcname,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type ListVirtualRouterElementsParams struct { - p map[string]interface{} -} - -func (p *ListVirtualRouterElementsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["enabled"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("enabled", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["nspid"]; found { - u.Set("nspid", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - return u -} - -func (p *ListVirtualRouterElementsParams) SetEnabled(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["enabled"] = v - return -} - -func (p *ListVirtualRouterElementsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListVirtualRouterElementsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListVirtualRouterElementsParams) SetNspid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["nspid"] = v - return -} - -func (p *ListVirtualRouterElementsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListVirtualRouterElementsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -// You should always use this function to get a new ListVirtualRouterElementsParams instance, -// as then you are sure you have configured all required params -func (s *RouterService) NewListVirtualRouterElementsParams() *ListVirtualRouterElementsParams { - p := &ListVirtualRouterElementsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *RouterService) GetVirtualRouterElementByID(id string, opts ...OptionFunc) (*VirtualRouterElement, int, error) { - p := &ListVirtualRouterElementsParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListVirtualRouterElements(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.VirtualRouterElements[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for VirtualRouterElement UUID: %s!", id) -} - -// Lists all available virtual router elements. -func (s *RouterService) ListVirtualRouterElements(p *ListVirtualRouterElementsParams) (*ListVirtualRouterElementsResponse, error) { - resp, err := s.cs.newRequest("listVirtualRouterElements", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListVirtualRouterElementsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListVirtualRouterElementsResponse struct { - Count int `json:"count"` - VirtualRouterElements []*VirtualRouterElement `json:"virtualrouterelement"` -} - -type VirtualRouterElement struct { - Account string `json:"account,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Enabled bool `json:"enabled,omitempty"` - Id string `json:"id,omitempty"` - Nspid string `json:"nspid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` -} - -type ConfigureVirtualRouterElementParams struct { - p map[string]interface{} -} - -func (p *ConfigureVirtualRouterElementParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["enabled"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("enabled", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *ConfigureVirtualRouterElementParams) SetEnabled(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["enabled"] = v - return -} - -func (p *ConfigureVirtualRouterElementParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new ConfigureVirtualRouterElementParams instance, -// as then you are sure you have configured all required params -func (s *RouterService) NewConfigureVirtualRouterElementParams(enabled bool, id string) *ConfigureVirtualRouterElementParams { - p := &ConfigureVirtualRouterElementParams{} - p.p = make(map[string]interface{}) - p.p["enabled"] = enabled - p.p["id"] = id - return p -} - -// Configures a virtual router element. -func (s *RouterService) ConfigureVirtualRouterElement(p *ConfigureVirtualRouterElementParams) (*ConfigureVirtualRouterElementResponse, error) { - resp, err := s.cs.newRequest("configureVirtualRouterElement", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ConfigureVirtualRouterElementResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type ConfigureVirtualRouterElementResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Enabled bool `json:"enabled,omitempty"` - Id string `json:"id,omitempty"` - Nspid string `json:"nspid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` -} - -type CreateVirtualRouterElementParams struct { - p map[string]interface{} -} - -func (p *CreateVirtualRouterElementParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["nspid"]; found { - u.Set("nspid", v.(string)) - } - if v, found := p.p["providertype"]; found { - u.Set("providertype", v.(string)) - } - return u -} - -func (p *CreateVirtualRouterElementParams) SetNspid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["nspid"] = v - return -} - -func (p *CreateVirtualRouterElementParams) SetProvidertype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["providertype"] = v - return -} - -// You should always use this function to get a new CreateVirtualRouterElementParams instance, -// as then you are sure you have configured all required params -func (s *RouterService) NewCreateVirtualRouterElementParams(nspid string) *CreateVirtualRouterElementParams { - p := &CreateVirtualRouterElementParams{} - p.p = make(map[string]interface{}) - p.p["nspid"] = nspid - return p -} - -// Create a virtual router element. -func (s *RouterService) CreateVirtualRouterElement(p *CreateVirtualRouterElementParams) (*CreateVirtualRouterElementResponse, error) { - resp, err := s.cs.newRequest("createVirtualRouterElement", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateVirtualRouterElementResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateVirtualRouterElementResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Enabled bool `json:"enabled,omitempty"` - Id string `json:"id,omitempty"` - Nspid string `json:"nspid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/SSHService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/SSHService.go deleted file mode 100644 index 2221a5921c2..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/SSHService.go +++ /dev/null @@ -1,746 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "net/url" - "strconv" -) - -type ResetSSHKeyForVirtualMachineParams struct { - p map[string]interface{} -} - -func (p *ResetSSHKeyForVirtualMachineParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["keypair"]; found { - u.Set("keypair", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - return u -} - -func (p *ResetSSHKeyForVirtualMachineParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ResetSSHKeyForVirtualMachineParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ResetSSHKeyForVirtualMachineParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ResetSSHKeyForVirtualMachineParams) SetKeypair(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keypair"] = v - return -} - -func (p *ResetSSHKeyForVirtualMachineParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -// You should always use this function to get a new ResetSSHKeyForVirtualMachineParams instance, -// as then you are sure you have configured all required params -func (s *SSHService) NewResetSSHKeyForVirtualMachineParams(id string, keypair string) *ResetSSHKeyForVirtualMachineParams { - p := &ResetSSHKeyForVirtualMachineParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - p.p["keypair"] = keypair - return p -} - -// Resets the SSH Key for virtual machine. The virtual machine must be in a "Stopped" state. [async] -func (s *SSHService) ResetSSHKeyForVirtualMachine(p *ResetSSHKeyForVirtualMachineParams) (*ResetSSHKeyForVirtualMachineResponse, error) { - resp, err := s.cs.newRequest("resetSSHKeyForVirtualMachine", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ResetSSHKeyForVirtualMachineResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type ResetSSHKeyForVirtualMachineResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Affinitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Type string `json:"type,omitempty"` - VirtualmachineIds []string `json:"virtualmachineIds,omitempty"` - } `json:"affinitygroup,omitempty"` - Cpunumber int `json:"cpunumber,omitempty"` - Cpuspeed int `json:"cpuspeed,omitempty"` - Cpuused string `json:"cpuused,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Diskioread int64 `json:"diskioread,omitempty"` - Diskiowrite int64 `json:"diskiowrite,omitempty"` - Diskkbsread int64 `json:"diskkbsread,omitempty"` - Diskkbswrite int64 `json:"diskkbswrite,omitempty"` - Diskofferingid string `json:"diskofferingid,omitempty"` - Diskofferingname string `json:"diskofferingname,omitempty"` - Displayname string `json:"displayname,omitempty"` - Displayvm bool `json:"displayvm,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"` - Group string `json:"group,omitempty"` - Groupid string `json:"groupid,omitempty"` - Guestosid string `json:"guestosid,omitempty"` - Haenable bool `json:"haenable,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Instancename string `json:"instancename,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isodisplaytext string `json:"isodisplaytext,omitempty"` - Isoid string `json:"isoid,omitempty"` - Isoname string `json:"isoname,omitempty"` - Keypair string `json:"keypair,omitempty"` - Memory int `json:"memory,omitempty"` - Name string `json:"name,omitempty"` - Networkkbsread int64 `json:"networkkbsread,omitempty"` - Networkkbswrite int64 `json:"networkkbswrite,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Ostypeid int64 `json:"ostypeid,omitempty"` - Password string `json:"password,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - Rootdeviceid int64 `json:"rootdeviceid,omitempty"` - Rootdevicetype string `json:"rootdevicetype,omitempty"` - Securitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Egressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"egressrule,omitempty"` - Id string `json:"id,omitempty"` - Ingressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"ingressrule,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinecount int `json:"virtualmachinecount,omitempty"` - Virtualmachineids []string `json:"virtualmachineids,omitempty"` - } `json:"securitygroup,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - Servicestate string `json:"servicestate,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatedisplaytext string `json:"templatedisplaytext,omitempty"` - Templateid string `json:"templateid,omitempty"` - Templatename string `json:"templatename,omitempty"` - Userid string `json:"userid,omitempty"` - Username string `json:"username,omitempty"` - Vgpu string `json:"vgpu,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type RegisterSSHKeyPairParams struct { - p map[string]interface{} -} - -func (p *RegisterSSHKeyPairParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["publickey"]; found { - u.Set("publickey", v.(string)) - } - return u -} - -func (p *RegisterSSHKeyPairParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *RegisterSSHKeyPairParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *RegisterSSHKeyPairParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *RegisterSSHKeyPairParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *RegisterSSHKeyPairParams) SetPublickey(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["publickey"] = v - return -} - -// You should always use this function to get a new RegisterSSHKeyPairParams instance, -// as then you are sure you have configured all required params -func (s *SSHService) NewRegisterSSHKeyPairParams(name string, publickey string) *RegisterSSHKeyPairParams { - p := &RegisterSSHKeyPairParams{} - p.p = make(map[string]interface{}) - p.p["name"] = name - p.p["publickey"] = publickey - return p -} - -// Register a public key in a keypair under a certain name -func (s *SSHService) RegisterSSHKeyPair(p *RegisterSSHKeyPairParams) (*RegisterSSHKeyPairResponse, error) { - resp, err := s.cs.newRequest("registerSSHKeyPair", p.toURLValues()) - if err != nil { - return nil, err - } - - if resp, err = getRawValue(resp); err != nil { - return nil, err - } - - var r RegisterSSHKeyPairResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type RegisterSSHKeyPairResponse struct { - Account string `json:"account,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fingerprint string `json:"fingerprint,omitempty"` - Name string `json:"name,omitempty"` -} - -type CreateSSHKeyPairParams struct { - p map[string]interface{} -} - -func (p *CreateSSHKeyPairParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - return u -} - -func (p *CreateSSHKeyPairParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *CreateSSHKeyPairParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *CreateSSHKeyPairParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *CreateSSHKeyPairParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -// You should always use this function to get a new CreateSSHKeyPairParams instance, -// as then you are sure you have configured all required params -func (s *SSHService) NewCreateSSHKeyPairParams(name string) *CreateSSHKeyPairParams { - p := &CreateSSHKeyPairParams{} - p.p = make(map[string]interface{}) - p.p["name"] = name - return p -} - -// Create a new keypair and returns the private key -func (s *SSHService) CreateSSHKeyPair(p *CreateSSHKeyPairParams) (*CreateSSHKeyPairResponse, error) { - resp, err := s.cs.newRequest("createSSHKeyPair", p.toURLValues()) - if err != nil { - return nil, err - } - - if resp, err = getRawValue(resp); err != nil { - return nil, err - } - - var r CreateSSHKeyPairResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type CreateSSHKeyPairResponse struct { - Privatekey string `json:"privatekey,omitempty"` -} - -type DeleteSSHKeyPairParams struct { - p map[string]interface{} -} - -func (p *DeleteSSHKeyPairParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - return u -} - -func (p *DeleteSSHKeyPairParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *DeleteSSHKeyPairParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *DeleteSSHKeyPairParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *DeleteSSHKeyPairParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -// You should always use this function to get a new DeleteSSHKeyPairParams instance, -// as then you are sure you have configured all required params -func (s *SSHService) NewDeleteSSHKeyPairParams(name string) *DeleteSSHKeyPairParams { - p := &DeleteSSHKeyPairParams{} - p.p = make(map[string]interface{}) - p.p["name"] = name - return p -} - -// Deletes a keypair by name -func (s *SSHService) DeleteSSHKeyPair(p *DeleteSSHKeyPairParams) (*DeleteSSHKeyPairResponse, error) { - resp, err := s.cs.newRequest("deleteSSHKeyPair", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteSSHKeyPairResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type DeleteSSHKeyPairResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} - -type ListSSHKeyPairsParams struct { - p map[string]interface{} -} - -func (p *ListSSHKeyPairsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["fingerprint"]; found { - u.Set("fingerprint", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - return u -} - -func (p *ListSSHKeyPairsParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListSSHKeyPairsParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListSSHKeyPairsParams) SetFingerprint(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fingerprint"] = v - return -} - -func (p *ListSSHKeyPairsParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListSSHKeyPairsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListSSHKeyPairsParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListSSHKeyPairsParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListSSHKeyPairsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListSSHKeyPairsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListSSHKeyPairsParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -// You should always use this function to get a new ListSSHKeyPairsParams instance, -// as then you are sure you have configured all required params -func (s *SSHService) NewListSSHKeyPairsParams() *ListSSHKeyPairsParams { - p := &ListSSHKeyPairsParams{} - p.p = make(map[string]interface{}) - return p -} - -// List registered keypairs -func (s *SSHService) ListSSHKeyPairs(p *ListSSHKeyPairsParams) (*ListSSHKeyPairsResponse, error) { - resp, err := s.cs.newRequest("listSSHKeyPairs", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListSSHKeyPairsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListSSHKeyPairsResponse struct { - Count int `json:"count"` - SSHKeyPairs []*SSHKeyPair `json:"sshkeypair"` -} - -type SSHKeyPair struct { - Account string `json:"account,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fingerprint string `json:"fingerprint,omitempty"` - Name string `json:"name,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/SecurityGroupService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/SecurityGroupService.go deleted file mode 100644 index 6eec7916a68..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/SecurityGroupService.go +++ /dev/null @@ -1,1190 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type CreateSecurityGroupParams struct { - p map[string]interface{} -} - -func (p *CreateSecurityGroupParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["description"]; found { - u.Set("description", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - return u -} - -func (p *CreateSecurityGroupParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *CreateSecurityGroupParams) SetDescription(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["description"] = v - return -} - -func (p *CreateSecurityGroupParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *CreateSecurityGroupParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *CreateSecurityGroupParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -// You should always use this function to get a new CreateSecurityGroupParams instance, -// as then you are sure you have configured all required params -func (s *SecurityGroupService) NewCreateSecurityGroupParams(name string) *CreateSecurityGroupParams { - p := &CreateSecurityGroupParams{} - p.p = make(map[string]interface{}) - p.p["name"] = name - return p -} - -// Creates a security group -func (s *SecurityGroupService) CreateSecurityGroup(p *CreateSecurityGroupParams) (*CreateSecurityGroupResponse, error) { - resp, err := s.cs.newRequest("createSecurityGroup", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateSecurityGroupResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type CreateSecurityGroupResponse struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Egressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"egressrule,omitempty"` - Id string `json:"id,omitempty"` - Ingressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"ingressrule,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinecount int `json:"virtualmachinecount,omitempty"` - Virtualmachineids []string `json:"virtualmachineids,omitempty"` -} - -type DeleteSecurityGroupParams struct { - p map[string]interface{} -} - -func (p *DeleteSecurityGroupParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - return u -} - -func (p *DeleteSecurityGroupParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *DeleteSecurityGroupParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *DeleteSecurityGroupParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *DeleteSecurityGroupParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *DeleteSecurityGroupParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -// You should always use this function to get a new DeleteSecurityGroupParams instance, -// as then you are sure you have configured all required params -func (s *SecurityGroupService) NewDeleteSecurityGroupParams() *DeleteSecurityGroupParams { - p := &DeleteSecurityGroupParams{} - p.p = make(map[string]interface{}) - return p -} - -// Deletes security group -func (s *SecurityGroupService) DeleteSecurityGroup(p *DeleteSecurityGroupParams) (*DeleteSecurityGroupResponse, error) { - resp, err := s.cs.newRequest("deleteSecurityGroup", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteSecurityGroupResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type DeleteSecurityGroupResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} - -type AuthorizeSecurityGroupIngressParams struct { - p map[string]interface{} -} - -func (p *AuthorizeSecurityGroupIngressParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["cidrlist"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("cidrlist", vv) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["endport"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("endport", vv) - } - if v, found := p.p["icmpcode"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("icmpcode", vv) - } - if v, found := p.p["icmptype"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("icmptype", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["protocol"]; found { - u.Set("protocol", v.(string)) - } - if v, found := p.p["securitygroupid"]; found { - u.Set("securitygroupid", v.(string)) - } - if v, found := p.p["securitygroupname"]; found { - u.Set("securitygroupname", v.(string)) - } - if v, found := p.p["startport"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("startport", vv) - } - if v, found := p.p["usersecuritygrouplist"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("usersecuritygrouplist[%d].key", i), k) - u.Set(fmt.Sprintf("usersecuritygrouplist[%d].value", i), vv) - i++ - } - } - return u -} - -func (p *AuthorizeSecurityGroupIngressParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *AuthorizeSecurityGroupIngressParams) SetCidrlist(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["cidrlist"] = v - return -} - -func (p *AuthorizeSecurityGroupIngressParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *AuthorizeSecurityGroupIngressParams) SetEndport(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["endport"] = v - return -} - -func (p *AuthorizeSecurityGroupIngressParams) SetIcmpcode(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["icmpcode"] = v - return -} - -func (p *AuthorizeSecurityGroupIngressParams) SetIcmptype(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["icmptype"] = v - return -} - -func (p *AuthorizeSecurityGroupIngressParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *AuthorizeSecurityGroupIngressParams) SetProtocol(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["protocol"] = v - return -} - -func (p *AuthorizeSecurityGroupIngressParams) SetSecuritygroupid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["securitygroupid"] = v - return -} - -func (p *AuthorizeSecurityGroupIngressParams) SetSecuritygroupname(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["securitygroupname"] = v - return -} - -func (p *AuthorizeSecurityGroupIngressParams) SetStartport(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["startport"] = v - return -} - -func (p *AuthorizeSecurityGroupIngressParams) SetUsersecuritygrouplist(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["usersecuritygrouplist"] = v - return -} - -// You should always use this function to get a new AuthorizeSecurityGroupIngressParams instance, -// as then you are sure you have configured all required params -func (s *SecurityGroupService) NewAuthorizeSecurityGroupIngressParams() *AuthorizeSecurityGroupIngressParams { - p := &AuthorizeSecurityGroupIngressParams{} - p.p = make(map[string]interface{}) - return p -} - -// Authorizes a particular ingress rule for this security group -func (s *SecurityGroupService) AuthorizeSecurityGroupIngress(p *AuthorizeSecurityGroupIngressParams) (*AuthorizeSecurityGroupIngressResponse, error) { - resp, err := s.cs.newRequest("authorizeSecurityGroupIngress", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AuthorizeSecurityGroupIngressResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type AuthorizeSecurityGroupIngressResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` -} - -type RevokeSecurityGroupIngressParams struct { - p map[string]interface{} -} - -func (p *RevokeSecurityGroupIngressParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *RevokeSecurityGroupIngressParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new RevokeSecurityGroupIngressParams instance, -// as then you are sure you have configured all required params -func (s *SecurityGroupService) NewRevokeSecurityGroupIngressParams(id string) *RevokeSecurityGroupIngressParams { - p := &RevokeSecurityGroupIngressParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a particular ingress rule from this security group -func (s *SecurityGroupService) RevokeSecurityGroupIngress(p *RevokeSecurityGroupIngressParams) (*RevokeSecurityGroupIngressResponse, error) { - resp, err := s.cs.newRequest("revokeSecurityGroupIngress", p.toURLValues()) - if err != nil { - return nil, err - } - - var r RevokeSecurityGroupIngressResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type RevokeSecurityGroupIngressResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type AuthorizeSecurityGroupEgressParams struct { - p map[string]interface{} -} - -func (p *AuthorizeSecurityGroupEgressParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["cidrlist"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("cidrlist", vv) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["endport"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("endport", vv) - } - if v, found := p.p["icmpcode"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("icmpcode", vv) - } - if v, found := p.p["icmptype"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("icmptype", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["protocol"]; found { - u.Set("protocol", v.(string)) - } - if v, found := p.p["securitygroupid"]; found { - u.Set("securitygroupid", v.(string)) - } - if v, found := p.p["securitygroupname"]; found { - u.Set("securitygroupname", v.(string)) - } - if v, found := p.p["startport"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("startport", vv) - } - if v, found := p.p["usersecuritygrouplist"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("usersecuritygrouplist[%d].key", i), k) - u.Set(fmt.Sprintf("usersecuritygrouplist[%d].value", i), vv) - i++ - } - } - return u -} - -func (p *AuthorizeSecurityGroupEgressParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *AuthorizeSecurityGroupEgressParams) SetCidrlist(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["cidrlist"] = v - return -} - -func (p *AuthorizeSecurityGroupEgressParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *AuthorizeSecurityGroupEgressParams) SetEndport(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["endport"] = v - return -} - -func (p *AuthorizeSecurityGroupEgressParams) SetIcmpcode(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["icmpcode"] = v - return -} - -func (p *AuthorizeSecurityGroupEgressParams) SetIcmptype(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["icmptype"] = v - return -} - -func (p *AuthorizeSecurityGroupEgressParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *AuthorizeSecurityGroupEgressParams) SetProtocol(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["protocol"] = v - return -} - -func (p *AuthorizeSecurityGroupEgressParams) SetSecuritygroupid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["securitygroupid"] = v - return -} - -func (p *AuthorizeSecurityGroupEgressParams) SetSecuritygroupname(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["securitygroupname"] = v - return -} - -func (p *AuthorizeSecurityGroupEgressParams) SetStartport(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["startport"] = v - return -} - -func (p *AuthorizeSecurityGroupEgressParams) SetUsersecuritygrouplist(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["usersecuritygrouplist"] = v - return -} - -// You should always use this function to get a new AuthorizeSecurityGroupEgressParams instance, -// as then you are sure you have configured all required params -func (s *SecurityGroupService) NewAuthorizeSecurityGroupEgressParams() *AuthorizeSecurityGroupEgressParams { - p := &AuthorizeSecurityGroupEgressParams{} - p.p = make(map[string]interface{}) - return p -} - -// Authorizes a particular egress rule for this security group -func (s *SecurityGroupService) AuthorizeSecurityGroupEgress(p *AuthorizeSecurityGroupEgressParams) (*AuthorizeSecurityGroupEgressResponse, error) { - resp, err := s.cs.newRequest("authorizeSecurityGroupEgress", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AuthorizeSecurityGroupEgressResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type AuthorizeSecurityGroupEgressResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` -} - -type RevokeSecurityGroupEgressParams struct { - p map[string]interface{} -} - -func (p *RevokeSecurityGroupEgressParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *RevokeSecurityGroupEgressParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new RevokeSecurityGroupEgressParams instance, -// as then you are sure you have configured all required params -func (s *SecurityGroupService) NewRevokeSecurityGroupEgressParams(id string) *RevokeSecurityGroupEgressParams { - p := &RevokeSecurityGroupEgressParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a particular egress rule from this security group -func (s *SecurityGroupService) RevokeSecurityGroupEgress(p *RevokeSecurityGroupEgressParams) (*RevokeSecurityGroupEgressResponse, error) { - resp, err := s.cs.newRequest("revokeSecurityGroupEgress", p.toURLValues()) - if err != nil { - return nil, err - } - - var r RevokeSecurityGroupEgressResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type RevokeSecurityGroupEgressResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListSecurityGroupsParams struct { - p map[string]interface{} -} - -func (p *ListSecurityGroupsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["securitygroupname"]; found { - u.Set("securitygroupname", v.(string)) - } - if v, found := p.p["tags"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("tags[%d].key", i), k) - u.Set(fmt.Sprintf("tags[%d].value", i), vv) - i++ - } - } - if v, found := p.p["virtualmachineid"]; found { - u.Set("virtualmachineid", v.(string)) - } - return u -} - -func (p *ListSecurityGroupsParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListSecurityGroupsParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListSecurityGroupsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListSecurityGroupsParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListSecurityGroupsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListSecurityGroupsParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListSecurityGroupsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListSecurityGroupsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListSecurityGroupsParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListSecurityGroupsParams) SetSecuritygroupname(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["securitygroupname"] = v - return -} - -func (p *ListSecurityGroupsParams) SetTags(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tags"] = v - return -} - -func (p *ListSecurityGroupsParams) SetVirtualmachineid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["virtualmachineid"] = v - return -} - -// You should always use this function to get a new ListSecurityGroupsParams instance, -// as then you are sure you have configured all required params -func (s *SecurityGroupService) NewListSecurityGroupsParams() *ListSecurityGroupsParams { - p := &ListSecurityGroupsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *SecurityGroupService) GetSecurityGroupID(keyword string, opts ...OptionFunc) (string, int, error) { - p := &ListSecurityGroupsParams{} - p.p = make(map[string]interface{}) - - p.p["keyword"] = keyword - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListSecurityGroups(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", keyword, l) - } - - if l.Count == 1 { - return l.SecurityGroups[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.SecurityGroups { - if v.Name == keyword { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *SecurityGroupService) GetSecurityGroupByName(name string, opts ...OptionFunc) (*SecurityGroup, int, error) { - id, count, err := s.GetSecurityGroupID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetSecurityGroupByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *SecurityGroupService) GetSecurityGroupByID(id string, opts ...OptionFunc) (*SecurityGroup, int, error) { - p := &ListSecurityGroupsParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListSecurityGroups(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.SecurityGroups[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for SecurityGroup UUID: %s!", id) -} - -// Lists security groups -func (s *SecurityGroupService) ListSecurityGroups(p *ListSecurityGroupsParams) (*ListSecurityGroupsResponse, error) { - resp, err := s.cs.newRequest("listSecurityGroups", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListSecurityGroupsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListSecurityGroupsResponse struct { - Count int `json:"count"` - SecurityGroups []*SecurityGroup `json:"securitygroup"` -} - -type SecurityGroup struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Egressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"egressrule,omitempty"` - Id string `json:"id,omitempty"` - Ingressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"ingressrule,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinecount int `json:"virtualmachinecount,omitempty"` - Virtualmachineids []string `json:"virtualmachineids,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/ServiceOfferingService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/ServiceOfferingService.go deleted file mode 100644 index 95e76470318..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/ServiceOfferingService.go +++ /dev/null @@ -1,853 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type CreateServiceOfferingParams struct { - p map[string]interface{} -} - -func (p *CreateServiceOfferingParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["bytesreadrate"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("bytesreadrate", vv) - } - if v, found := p.p["byteswriterate"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("byteswriterate", vv) - } - if v, found := p.p["cpunumber"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("cpunumber", vv) - } - if v, found := p.p["cpuspeed"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("cpuspeed", vv) - } - if v, found := p.p["customizediops"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("customizediops", vv) - } - if v, found := p.p["deploymentplanner"]; found { - u.Set("deploymentplanner", v.(string)) - } - if v, found := p.p["displaytext"]; found { - u.Set("displaytext", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["hosttags"]; found { - u.Set("hosttags", v.(string)) - } - if v, found := p.p["hypervisorsnapshotreserve"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("hypervisorsnapshotreserve", vv) - } - if v, found := p.p["iopsreadrate"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("iopsreadrate", vv) - } - if v, found := p.p["iopswriterate"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("iopswriterate", vv) - } - if v, found := p.p["issystem"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("issystem", vv) - } - if v, found := p.p["isvolatile"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isvolatile", vv) - } - if v, found := p.p["limitcpuuse"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("limitcpuuse", vv) - } - if v, found := p.p["maxiops"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("maxiops", vv) - } - if v, found := p.p["memory"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("memory", vv) - } - if v, found := p.p["miniops"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("miniops", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["networkrate"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("networkrate", vv) - } - if v, found := p.p["offerha"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("offerha", vv) - } - if v, found := p.p["provisioningtype"]; found { - u.Set("provisioningtype", v.(string)) - } - if v, found := p.p["serviceofferingdetails"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("serviceofferingdetails[%d].key", i), k) - u.Set(fmt.Sprintf("serviceofferingdetails[%d].value", i), vv) - i++ - } - } - if v, found := p.p["storagetype"]; found { - u.Set("storagetype", v.(string)) - } - if v, found := p.p["systemvmtype"]; found { - u.Set("systemvmtype", v.(string)) - } - if v, found := p.p["tags"]; found { - u.Set("tags", v.(string)) - } - return u -} - -func (p *CreateServiceOfferingParams) SetBytesreadrate(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["bytesreadrate"] = v - return -} - -func (p *CreateServiceOfferingParams) SetByteswriterate(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["byteswriterate"] = v - return -} - -func (p *CreateServiceOfferingParams) SetCpunumber(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["cpunumber"] = v - return -} - -func (p *CreateServiceOfferingParams) SetCpuspeed(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["cpuspeed"] = v - return -} - -func (p *CreateServiceOfferingParams) SetCustomizediops(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["customizediops"] = v - return -} - -func (p *CreateServiceOfferingParams) SetDeploymentplanner(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["deploymentplanner"] = v - return -} - -func (p *CreateServiceOfferingParams) SetDisplaytext(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displaytext"] = v - return -} - -func (p *CreateServiceOfferingParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *CreateServiceOfferingParams) SetHosttags(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hosttags"] = v - return -} - -func (p *CreateServiceOfferingParams) SetHypervisorsnapshotreserve(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hypervisorsnapshotreserve"] = v - return -} - -func (p *CreateServiceOfferingParams) SetIopsreadrate(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["iopsreadrate"] = v - return -} - -func (p *CreateServiceOfferingParams) SetIopswriterate(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["iopswriterate"] = v - return -} - -func (p *CreateServiceOfferingParams) SetIssystem(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["issystem"] = v - return -} - -func (p *CreateServiceOfferingParams) SetIsvolatile(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isvolatile"] = v - return -} - -func (p *CreateServiceOfferingParams) SetLimitcpuuse(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["limitcpuuse"] = v - return -} - -func (p *CreateServiceOfferingParams) SetMaxiops(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["maxiops"] = v - return -} - -func (p *CreateServiceOfferingParams) SetMemory(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["memory"] = v - return -} - -func (p *CreateServiceOfferingParams) SetMiniops(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["miniops"] = v - return -} - -func (p *CreateServiceOfferingParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *CreateServiceOfferingParams) SetNetworkrate(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkrate"] = v - return -} - -func (p *CreateServiceOfferingParams) SetOfferha(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["offerha"] = v - return -} - -func (p *CreateServiceOfferingParams) SetProvisioningtype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["provisioningtype"] = v - return -} - -func (p *CreateServiceOfferingParams) SetServiceofferingdetails(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["serviceofferingdetails"] = v - return -} - -func (p *CreateServiceOfferingParams) SetStoragetype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["storagetype"] = v - return -} - -func (p *CreateServiceOfferingParams) SetSystemvmtype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["systemvmtype"] = v - return -} - -func (p *CreateServiceOfferingParams) SetTags(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tags"] = v - return -} - -// You should always use this function to get a new CreateServiceOfferingParams instance, -// as then you are sure you have configured all required params -func (s *ServiceOfferingService) NewCreateServiceOfferingParams(displaytext string, name string) *CreateServiceOfferingParams { - p := &CreateServiceOfferingParams{} - p.p = make(map[string]interface{}) - p.p["displaytext"] = displaytext - p.p["name"] = name - return p -} - -// Creates a service offering. -func (s *ServiceOfferingService) CreateServiceOffering(p *CreateServiceOfferingParams) (*CreateServiceOfferingResponse, error) { - resp, err := s.cs.newRequest("createServiceOffering", p.toURLValues()) - if err != nil { - return nil, err - } - - if resp, err = getRawValue(resp); err != nil { - return nil, err - } - - var r CreateServiceOfferingResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type CreateServiceOfferingResponse struct { - Cpunumber int `json:"cpunumber,omitempty"` - Cpuspeed int `json:"cpuspeed,omitempty"` - Created string `json:"created,omitempty"` - Defaultuse bool `json:"defaultuse,omitempty"` - Deploymentplanner string `json:"deploymentplanner,omitempty"` - DiskBytesReadRate int64 `json:"diskBytesReadRate,omitempty"` - DiskBytesWriteRate int64 `json:"diskBytesWriteRate,omitempty"` - DiskIopsReadRate int64 `json:"diskIopsReadRate,omitempty"` - DiskIopsWriteRate int64 `json:"diskIopsWriteRate,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Hosttags string `json:"hosttags,omitempty"` - Hypervisorsnapshotreserve int `json:"hypervisorsnapshotreserve,omitempty"` - Id string `json:"id,omitempty"` - Iscustomized bool `json:"iscustomized,omitempty"` - Iscustomizediops bool `json:"iscustomizediops,omitempty"` - Issystem bool `json:"issystem,omitempty"` - Isvolatile bool `json:"isvolatile,omitempty"` - Limitcpuuse bool `json:"limitcpuuse,omitempty"` - Maxiops int64 `json:"maxiops,omitempty"` - Memory int `json:"memory,omitempty"` - Miniops int64 `json:"miniops,omitempty"` - Name string `json:"name,omitempty"` - Networkrate int `json:"networkrate,omitempty"` - Offerha bool `json:"offerha,omitempty"` - Provisioningtype string `json:"provisioningtype,omitempty"` - Serviceofferingdetails map[string]string `json:"serviceofferingdetails,omitempty"` - Storagetype string `json:"storagetype,omitempty"` - Systemvmtype string `json:"systemvmtype,omitempty"` - Tags string `json:"tags,omitempty"` -} - -type DeleteServiceOfferingParams struct { - p map[string]interface{} -} - -func (p *DeleteServiceOfferingParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteServiceOfferingParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteServiceOfferingParams instance, -// as then you are sure you have configured all required params -func (s *ServiceOfferingService) NewDeleteServiceOfferingParams(id string) *DeleteServiceOfferingParams { - p := &DeleteServiceOfferingParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a service offering. -func (s *ServiceOfferingService) DeleteServiceOffering(p *DeleteServiceOfferingParams) (*DeleteServiceOfferingResponse, error) { - resp, err := s.cs.newRequest("deleteServiceOffering", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteServiceOfferingResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type DeleteServiceOfferingResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} - -type UpdateServiceOfferingParams struct { - p map[string]interface{} -} - -func (p *UpdateServiceOfferingParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["displaytext"]; found { - u.Set("displaytext", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["sortkey"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("sortkey", vv) - } - return u -} - -func (p *UpdateServiceOfferingParams) SetDisplaytext(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displaytext"] = v - return -} - -func (p *UpdateServiceOfferingParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateServiceOfferingParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *UpdateServiceOfferingParams) SetSortkey(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["sortkey"] = v - return -} - -// You should always use this function to get a new UpdateServiceOfferingParams instance, -// as then you are sure you have configured all required params -func (s *ServiceOfferingService) NewUpdateServiceOfferingParams(id string) *UpdateServiceOfferingParams { - p := &UpdateServiceOfferingParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates a service offering. -func (s *ServiceOfferingService) UpdateServiceOffering(p *UpdateServiceOfferingParams) (*UpdateServiceOfferingResponse, error) { - resp, err := s.cs.newRequest("updateServiceOffering", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateServiceOfferingResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type UpdateServiceOfferingResponse struct { - Cpunumber int `json:"cpunumber,omitempty"` - Cpuspeed int `json:"cpuspeed,omitempty"` - Created string `json:"created,omitempty"` - Defaultuse bool `json:"defaultuse,omitempty"` - Deploymentplanner string `json:"deploymentplanner,omitempty"` - DiskBytesReadRate int64 `json:"diskBytesReadRate,omitempty"` - DiskBytesWriteRate int64 `json:"diskBytesWriteRate,omitempty"` - DiskIopsReadRate int64 `json:"diskIopsReadRate,omitempty"` - DiskIopsWriteRate int64 `json:"diskIopsWriteRate,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Hosttags string `json:"hosttags,omitempty"` - Hypervisorsnapshotreserve int `json:"hypervisorsnapshotreserve,omitempty"` - Id string `json:"id,omitempty"` - Iscustomized bool `json:"iscustomized,omitempty"` - Iscustomizediops bool `json:"iscustomizediops,omitempty"` - Issystem bool `json:"issystem,omitempty"` - Isvolatile bool `json:"isvolatile,omitempty"` - Limitcpuuse bool `json:"limitcpuuse,omitempty"` - Maxiops int64 `json:"maxiops,omitempty"` - Memory int `json:"memory,omitempty"` - Miniops int64 `json:"miniops,omitempty"` - Name string `json:"name,omitempty"` - Networkrate int `json:"networkrate,omitempty"` - Offerha bool `json:"offerha,omitempty"` - Provisioningtype string `json:"provisioningtype,omitempty"` - Serviceofferingdetails map[string]string `json:"serviceofferingdetails,omitempty"` - Storagetype string `json:"storagetype,omitempty"` - Systemvmtype string `json:"systemvmtype,omitempty"` - Tags string `json:"tags,omitempty"` -} - -type ListServiceOfferingsParams struct { - p map[string]interface{} -} - -func (p *ListServiceOfferingsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["issystem"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("issystem", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["systemvmtype"]; found { - u.Set("systemvmtype", v.(string)) - } - if v, found := p.p["virtualmachineid"]; found { - u.Set("virtualmachineid", v.(string)) - } - return u -} - -func (p *ListServiceOfferingsParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListServiceOfferingsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListServiceOfferingsParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListServiceOfferingsParams) SetIssystem(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["issystem"] = v - return -} - -func (p *ListServiceOfferingsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListServiceOfferingsParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListServiceOfferingsParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListServiceOfferingsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListServiceOfferingsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListServiceOfferingsParams) SetSystemvmtype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["systemvmtype"] = v - return -} - -func (p *ListServiceOfferingsParams) SetVirtualmachineid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["virtualmachineid"] = v - return -} - -// You should always use this function to get a new ListServiceOfferingsParams instance, -// as then you are sure you have configured all required params -func (s *ServiceOfferingService) NewListServiceOfferingsParams() *ListServiceOfferingsParams { - p := &ListServiceOfferingsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *ServiceOfferingService) GetServiceOfferingID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListServiceOfferingsParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListServiceOfferings(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.ServiceOfferings[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.ServiceOfferings { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *ServiceOfferingService) GetServiceOfferingByName(name string, opts ...OptionFunc) (*ServiceOffering, int, error) { - id, count, err := s.GetServiceOfferingID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetServiceOfferingByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *ServiceOfferingService) GetServiceOfferingByID(id string, opts ...OptionFunc) (*ServiceOffering, int, error) { - p := &ListServiceOfferingsParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListServiceOfferings(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.ServiceOfferings[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for ServiceOffering UUID: %s!", id) -} - -// Lists all available service offerings. -func (s *ServiceOfferingService) ListServiceOfferings(p *ListServiceOfferingsParams) (*ListServiceOfferingsResponse, error) { - resp, err := s.cs.newRequest("listServiceOfferings", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListServiceOfferingsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListServiceOfferingsResponse struct { - Count int `json:"count"` - ServiceOfferings []*ServiceOffering `json:"serviceoffering"` -} - -type ServiceOffering struct { - Cpunumber int `json:"cpunumber,omitempty"` - Cpuspeed int `json:"cpuspeed,omitempty"` - Created string `json:"created,omitempty"` - Defaultuse bool `json:"defaultuse,omitempty"` - Deploymentplanner string `json:"deploymentplanner,omitempty"` - DiskBytesReadRate int64 `json:"diskBytesReadRate,omitempty"` - DiskBytesWriteRate int64 `json:"diskBytesWriteRate,omitempty"` - DiskIopsReadRate int64 `json:"diskIopsReadRate,omitempty"` - DiskIopsWriteRate int64 `json:"diskIopsWriteRate,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Hosttags string `json:"hosttags,omitempty"` - Hypervisorsnapshotreserve int `json:"hypervisorsnapshotreserve,omitempty"` - Id string `json:"id,omitempty"` - Iscustomized bool `json:"iscustomized,omitempty"` - Iscustomizediops bool `json:"iscustomizediops,omitempty"` - Issystem bool `json:"issystem,omitempty"` - Isvolatile bool `json:"isvolatile,omitempty"` - Limitcpuuse bool `json:"limitcpuuse,omitempty"` - Maxiops int64 `json:"maxiops,omitempty"` - Memory int `json:"memory,omitempty"` - Miniops int64 `json:"miniops,omitempty"` - Name string `json:"name,omitempty"` - Networkrate int `json:"networkrate,omitempty"` - Offerha bool `json:"offerha,omitempty"` - Provisioningtype string `json:"provisioningtype,omitempty"` - Serviceofferingdetails map[string]string `json:"serviceofferingdetails,omitempty"` - Storagetype string `json:"storagetype,omitempty"` - Systemvmtype string `json:"systemvmtype,omitempty"` - Tags string `json:"tags,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/SnapshotService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/SnapshotService.go deleted file mode 100644 index c81dea32384..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/SnapshotService.go +++ /dev/null @@ -1,1793 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type CreateSnapshotParams struct { - p map[string]interface{} -} - -func (p *CreateSnapshotParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["policyid"]; found { - u.Set("policyid", v.(string)) - } - if v, found := p.p["quiescevm"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("quiescevm", vv) - } - if v, found := p.p["volumeid"]; found { - u.Set("volumeid", v.(string)) - } - return u -} - -func (p *CreateSnapshotParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *CreateSnapshotParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *CreateSnapshotParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *CreateSnapshotParams) SetPolicyid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["policyid"] = v - return -} - -func (p *CreateSnapshotParams) SetQuiescevm(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["quiescevm"] = v - return -} - -func (p *CreateSnapshotParams) SetVolumeid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["volumeid"] = v - return -} - -// You should always use this function to get a new CreateSnapshotParams instance, -// as then you are sure you have configured all required params -func (s *SnapshotService) NewCreateSnapshotParams(volumeid string) *CreateSnapshotParams { - p := &CreateSnapshotParams{} - p.p = make(map[string]interface{}) - p.p["volumeid"] = volumeid - return p -} - -// Creates an instant snapshot of a volume. -func (s *SnapshotService) CreateSnapshot(p *CreateSnapshotParams) (*CreateSnapshotResponse, error) { - resp, err := s.cs.newRequest("createSnapshot", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateSnapshotResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateSnapshotResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Created string `json:"created,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Intervaltype string `json:"intervaltype,omitempty"` - Name string `json:"name,omitempty"` - Physicalsize int64 `json:"physicalsize,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Revertable bool `json:"revertable,omitempty"` - Snapshottype string `json:"snapshottype,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Volumeid string `json:"volumeid,omitempty"` - Volumename string `json:"volumename,omitempty"` - Volumetype string `json:"volumetype,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type ListSnapshotsParams struct { - p map[string]interface{} -} - -func (p *ListSnapshotsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["intervaltype"]; found { - u.Set("intervaltype", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["snapshottype"]; found { - u.Set("snapshottype", v.(string)) - } - if v, found := p.p["tags"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("tags[%d].key", i), k) - u.Set(fmt.Sprintf("tags[%d].value", i), vv) - i++ - } - } - if v, found := p.p["volumeid"]; found { - u.Set("volumeid", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ListSnapshotsParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListSnapshotsParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListSnapshotsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListSnapshotsParams) SetIntervaltype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["intervaltype"] = v - return -} - -func (p *ListSnapshotsParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListSnapshotsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListSnapshotsParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListSnapshotsParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListSnapshotsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListSnapshotsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListSnapshotsParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListSnapshotsParams) SetSnapshottype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["snapshottype"] = v - return -} - -func (p *ListSnapshotsParams) SetTags(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tags"] = v - return -} - -func (p *ListSnapshotsParams) SetVolumeid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["volumeid"] = v - return -} - -func (p *ListSnapshotsParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ListSnapshotsParams instance, -// as then you are sure you have configured all required params -func (s *SnapshotService) NewListSnapshotsParams() *ListSnapshotsParams { - p := &ListSnapshotsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *SnapshotService) GetSnapshotID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListSnapshotsParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListSnapshots(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.Snapshots[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.Snapshots { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *SnapshotService) GetSnapshotByName(name string, opts ...OptionFunc) (*Snapshot, int, error) { - id, count, err := s.GetSnapshotID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetSnapshotByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *SnapshotService) GetSnapshotByID(id string, opts ...OptionFunc) (*Snapshot, int, error) { - p := &ListSnapshotsParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListSnapshots(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.Snapshots[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for Snapshot UUID: %s!", id) -} - -// Lists all available snapshots for the account. -func (s *SnapshotService) ListSnapshots(p *ListSnapshotsParams) (*ListSnapshotsResponse, error) { - resp, err := s.cs.newRequest("listSnapshots", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListSnapshotsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListSnapshotsResponse struct { - Count int `json:"count"` - Snapshots []*Snapshot `json:"snapshot"` -} - -type Snapshot struct { - Account string `json:"account,omitempty"` - Created string `json:"created,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Intervaltype string `json:"intervaltype,omitempty"` - Name string `json:"name,omitempty"` - Physicalsize int64 `json:"physicalsize,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Revertable bool `json:"revertable,omitempty"` - Snapshottype string `json:"snapshottype,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Volumeid string `json:"volumeid,omitempty"` - Volumename string `json:"volumename,omitempty"` - Volumetype string `json:"volumetype,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type DeleteSnapshotParams struct { - p map[string]interface{} -} - -func (p *DeleteSnapshotParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteSnapshotParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteSnapshotParams instance, -// as then you are sure you have configured all required params -func (s *SnapshotService) NewDeleteSnapshotParams(id string) *DeleteSnapshotParams { - p := &DeleteSnapshotParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a snapshot of a disk volume. -func (s *SnapshotService) DeleteSnapshot(p *DeleteSnapshotParams) (*DeleteSnapshotResponse, error) { - resp, err := s.cs.newRequest("deleteSnapshot", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteSnapshotResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteSnapshotResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type CreateSnapshotPolicyParams struct { - p map[string]interface{} -} - -func (p *CreateSnapshotPolicyParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["intervaltype"]; found { - u.Set("intervaltype", v.(string)) - } - if v, found := p.p["maxsnaps"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("maxsnaps", vv) - } - if v, found := p.p["schedule"]; found { - u.Set("schedule", v.(string)) - } - if v, found := p.p["timezone"]; found { - u.Set("timezone", v.(string)) - } - if v, found := p.p["volumeid"]; found { - u.Set("volumeid", v.(string)) - } - return u -} - -func (p *CreateSnapshotPolicyParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *CreateSnapshotPolicyParams) SetIntervaltype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["intervaltype"] = v - return -} - -func (p *CreateSnapshotPolicyParams) SetMaxsnaps(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["maxsnaps"] = v - return -} - -func (p *CreateSnapshotPolicyParams) SetSchedule(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["schedule"] = v - return -} - -func (p *CreateSnapshotPolicyParams) SetTimezone(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["timezone"] = v - return -} - -func (p *CreateSnapshotPolicyParams) SetVolumeid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["volumeid"] = v - return -} - -// You should always use this function to get a new CreateSnapshotPolicyParams instance, -// as then you are sure you have configured all required params -func (s *SnapshotService) NewCreateSnapshotPolicyParams(intervaltype string, maxsnaps int, schedule string, timezone string, volumeid string) *CreateSnapshotPolicyParams { - p := &CreateSnapshotPolicyParams{} - p.p = make(map[string]interface{}) - p.p["intervaltype"] = intervaltype - p.p["maxsnaps"] = maxsnaps - p.p["schedule"] = schedule - p.p["timezone"] = timezone - p.p["volumeid"] = volumeid - return p -} - -// Creates a snapshot policy for the account. -func (s *SnapshotService) CreateSnapshotPolicy(p *CreateSnapshotPolicyParams) (*CreateSnapshotPolicyResponse, error) { - resp, err := s.cs.newRequest("createSnapshotPolicy", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateSnapshotPolicyResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type CreateSnapshotPolicyResponse struct { - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Intervaltype int `json:"intervaltype,omitempty"` - Maxsnaps int `json:"maxsnaps,omitempty"` - Schedule string `json:"schedule,omitempty"` - Timezone string `json:"timezone,omitempty"` - Volumeid string `json:"volumeid,omitempty"` -} - -type UpdateSnapshotPolicyParams struct { - p map[string]interface{} -} - -func (p *UpdateSnapshotPolicyParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["customid"]; found { - u.Set("customid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *UpdateSnapshotPolicyParams) SetCustomid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["customid"] = v - return -} - -func (p *UpdateSnapshotPolicyParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *UpdateSnapshotPolicyParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new UpdateSnapshotPolicyParams instance, -// as then you are sure you have configured all required params -func (s *SnapshotService) NewUpdateSnapshotPolicyParams() *UpdateSnapshotPolicyParams { - p := &UpdateSnapshotPolicyParams{} - p.p = make(map[string]interface{}) - return p -} - -// Updates the snapshot policy. -func (s *SnapshotService) UpdateSnapshotPolicy(p *UpdateSnapshotPolicyParams) (*UpdateSnapshotPolicyResponse, error) { - resp, err := s.cs.newRequest("updateSnapshotPolicy", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateSnapshotPolicyResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateSnapshotPolicyResponse struct { - JobID string `json:"jobid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Intervaltype int `json:"intervaltype,omitempty"` - Maxsnaps int `json:"maxsnaps,omitempty"` - Schedule string `json:"schedule,omitempty"` - Timezone string `json:"timezone,omitempty"` - Volumeid string `json:"volumeid,omitempty"` -} - -type DeleteSnapshotPoliciesParams struct { - p map[string]interface{} -} - -func (p *DeleteSnapshotPoliciesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["ids"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("ids", vv) - } - return u -} - -func (p *DeleteSnapshotPoliciesParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *DeleteSnapshotPoliciesParams) SetIds(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ids"] = v - return -} - -// You should always use this function to get a new DeleteSnapshotPoliciesParams instance, -// as then you are sure you have configured all required params -func (s *SnapshotService) NewDeleteSnapshotPoliciesParams() *DeleteSnapshotPoliciesParams { - p := &DeleteSnapshotPoliciesParams{} - p.p = make(map[string]interface{}) - return p -} - -// Deletes snapshot policies for the account. -func (s *SnapshotService) DeleteSnapshotPolicies(p *DeleteSnapshotPoliciesParams) (*DeleteSnapshotPoliciesResponse, error) { - resp, err := s.cs.newRequest("deleteSnapshotPolicies", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteSnapshotPoliciesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type DeleteSnapshotPoliciesResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} - -type ListSnapshotPoliciesParams struct { - p map[string]interface{} -} - -func (p *ListSnapshotPoliciesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["volumeid"]; found { - u.Set("volumeid", v.(string)) - } - return u -} - -func (p *ListSnapshotPoliciesParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *ListSnapshotPoliciesParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListSnapshotPoliciesParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListSnapshotPoliciesParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListSnapshotPoliciesParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListSnapshotPoliciesParams) SetVolumeid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["volumeid"] = v - return -} - -// You should always use this function to get a new ListSnapshotPoliciesParams instance, -// as then you are sure you have configured all required params -func (s *SnapshotService) NewListSnapshotPoliciesParams() *ListSnapshotPoliciesParams { - p := &ListSnapshotPoliciesParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *SnapshotService) GetSnapshotPolicyByID(id string, opts ...OptionFunc) (*SnapshotPolicy, int, error) { - p := &ListSnapshotPoliciesParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListSnapshotPolicies(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.SnapshotPolicies[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for SnapshotPolicy UUID: %s!", id) -} - -// Lists snapshot policies. -func (s *SnapshotService) ListSnapshotPolicies(p *ListSnapshotPoliciesParams) (*ListSnapshotPoliciesResponse, error) { - resp, err := s.cs.newRequest("listSnapshotPolicies", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListSnapshotPoliciesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListSnapshotPoliciesResponse struct { - Count int `json:"count"` - SnapshotPolicies []*SnapshotPolicy `json:"snapshotpolicy"` -} - -type SnapshotPolicy struct { - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Intervaltype int `json:"intervaltype,omitempty"` - Maxsnaps int `json:"maxsnaps,omitempty"` - Schedule string `json:"schedule,omitempty"` - Timezone string `json:"timezone,omitempty"` - Volumeid string `json:"volumeid,omitempty"` -} - -type RevertSnapshotParams struct { - p map[string]interface{} -} - -func (p *RevertSnapshotParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *RevertSnapshotParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new RevertSnapshotParams instance, -// as then you are sure you have configured all required params -func (s *SnapshotService) NewRevertSnapshotParams(id string) *RevertSnapshotParams { - p := &RevertSnapshotParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// revert a volume snapshot. -func (s *SnapshotService) RevertSnapshot(p *RevertSnapshotParams) (*RevertSnapshotResponse, error) { - resp, err := s.cs.newRequest("revertSnapshot", p.toURLValues()) - if err != nil { - return nil, err - } - - var r RevertSnapshotResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type RevertSnapshotResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Created string `json:"created,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Intervaltype string `json:"intervaltype,omitempty"` - Name string `json:"name,omitempty"` - Physicalsize int64 `json:"physicalsize,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Revertable bool `json:"revertable,omitempty"` - Snapshottype string `json:"snapshottype,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Volumeid string `json:"volumeid,omitempty"` - Volumename string `json:"volumename,omitempty"` - Volumetype string `json:"volumetype,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type ListVMSnapshotParams struct { - p map[string]interface{} -} - -func (p *ListVMSnapshotParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["state"]; found { - u.Set("state", v.(string)) - } - if v, found := p.p["tags"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("tags[%d].key", i), k) - u.Set(fmt.Sprintf("tags[%d].value", i), vv) - i++ - } - } - if v, found := p.p["virtualmachineid"]; found { - u.Set("virtualmachineid", v.(string)) - } - if v, found := p.p["vmsnapshotid"]; found { - u.Set("vmsnapshotid", v.(string)) - } - return u -} - -func (p *ListVMSnapshotParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListVMSnapshotParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListVMSnapshotParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListVMSnapshotParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListVMSnapshotParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListVMSnapshotParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListVMSnapshotParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListVMSnapshotParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListVMSnapshotParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListVMSnapshotParams) SetState(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["state"] = v - return -} - -func (p *ListVMSnapshotParams) SetTags(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tags"] = v - return -} - -func (p *ListVMSnapshotParams) SetVirtualmachineid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["virtualmachineid"] = v - return -} - -func (p *ListVMSnapshotParams) SetVmsnapshotid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vmsnapshotid"] = v - return -} - -// You should always use this function to get a new ListVMSnapshotParams instance, -// as then you are sure you have configured all required params -func (s *SnapshotService) NewListVMSnapshotParams() *ListVMSnapshotParams { - p := &ListVMSnapshotParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *SnapshotService) GetVMSnapshotID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListVMSnapshotParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListVMSnapshot(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.VMSnapshot[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.VMSnapshot { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// List virtual machine snapshot by conditions -func (s *SnapshotService) ListVMSnapshot(p *ListVMSnapshotParams) (*ListVMSnapshotResponse, error) { - resp, err := s.cs.newRequest("listVMSnapshot", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListVMSnapshotResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListVMSnapshotResponse struct { - Count int `json:"count"` - VMSnapshot []*VMSnapshot `json:"vmsnapshot"` -} - -type VMSnapshot struct { - Account string `json:"account,omitempty"` - Created string `json:"created,omitempty"` - Current bool `json:"current,omitempty"` - Description string `json:"description,omitempty"` - Displayname string `json:"displayname,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Parent string `json:"parent,omitempty"` - ParentName string `json:"parentName,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - State string `json:"state,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type CreateVMSnapshotParams struct { - p map[string]interface{} -} - -func (p *CreateVMSnapshotParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["description"]; found { - u.Set("description", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["quiescevm"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("quiescevm", vv) - } - if v, found := p.p["snapshotmemory"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("snapshotmemory", vv) - } - if v, found := p.p["virtualmachineid"]; found { - u.Set("virtualmachineid", v.(string)) - } - return u -} - -func (p *CreateVMSnapshotParams) SetDescription(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["description"] = v - return -} - -func (p *CreateVMSnapshotParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *CreateVMSnapshotParams) SetQuiescevm(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["quiescevm"] = v - return -} - -func (p *CreateVMSnapshotParams) SetSnapshotmemory(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["snapshotmemory"] = v - return -} - -func (p *CreateVMSnapshotParams) SetVirtualmachineid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["virtualmachineid"] = v - return -} - -// You should always use this function to get a new CreateVMSnapshotParams instance, -// as then you are sure you have configured all required params -func (s *SnapshotService) NewCreateVMSnapshotParams(virtualmachineid string) *CreateVMSnapshotParams { - p := &CreateVMSnapshotParams{} - p.p = make(map[string]interface{}) - p.p["virtualmachineid"] = virtualmachineid - return p -} - -// Creates snapshot for a vm. -func (s *SnapshotService) CreateVMSnapshot(p *CreateVMSnapshotParams) (*CreateVMSnapshotResponse, error) { - resp, err := s.cs.newRequest("createVMSnapshot", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateVMSnapshotResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateVMSnapshotResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Created string `json:"created,omitempty"` - Current bool `json:"current,omitempty"` - Description string `json:"description,omitempty"` - Displayname string `json:"displayname,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Parent string `json:"parent,omitempty"` - ParentName string `json:"parentName,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - State string `json:"state,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type DeleteVMSnapshotParams struct { - p map[string]interface{} -} - -func (p *DeleteVMSnapshotParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["vmsnapshotid"]; found { - u.Set("vmsnapshotid", v.(string)) - } - return u -} - -func (p *DeleteVMSnapshotParams) SetVmsnapshotid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vmsnapshotid"] = v - return -} - -// You should always use this function to get a new DeleteVMSnapshotParams instance, -// as then you are sure you have configured all required params -func (s *SnapshotService) NewDeleteVMSnapshotParams(vmsnapshotid string) *DeleteVMSnapshotParams { - p := &DeleteVMSnapshotParams{} - p.p = make(map[string]interface{}) - p.p["vmsnapshotid"] = vmsnapshotid - return p -} - -// Deletes a vmsnapshot. -func (s *SnapshotService) DeleteVMSnapshot(p *DeleteVMSnapshotParams) (*DeleteVMSnapshotResponse, error) { - resp, err := s.cs.newRequest("deleteVMSnapshot", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteVMSnapshotResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteVMSnapshotResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type RevertToVMSnapshotParams struct { - p map[string]interface{} -} - -func (p *RevertToVMSnapshotParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["vmsnapshotid"]; found { - u.Set("vmsnapshotid", v.(string)) - } - return u -} - -func (p *RevertToVMSnapshotParams) SetVmsnapshotid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vmsnapshotid"] = v - return -} - -// You should always use this function to get a new RevertToVMSnapshotParams instance, -// as then you are sure you have configured all required params -func (s *SnapshotService) NewRevertToVMSnapshotParams(vmsnapshotid string) *RevertToVMSnapshotParams { - p := &RevertToVMSnapshotParams{} - p.p = make(map[string]interface{}) - p.p["vmsnapshotid"] = vmsnapshotid - return p -} - -// Revert VM from a vmsnapshot. -func (s *SnapshotService) RevertToVMSnapshot(p *RevertToVMSnapshotParams) (*RevertToVMSnapshotResponse, error) { - resp, err := s.cs.newRequest("revertToVMSnapshot", p.toURLValues()) - if err != nil { - return nil, err - } - - var r RevertToVMSnapshotResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type RevertToVMSnapshotResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Affinitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Type string `json:"type,omitempty"` - VirtualmachineIds []string `json:"virtualmachineIds,omitempty"` - } `json:"affinitygroup,omitempty"` - Cpunumber int `json:"cpunumber,omitempty"` - Cpuspeed int `json:"cpuspeed,omitempty"` - Cpuused string `json:"cpuused,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Diskioread int64 `json:"diskioread,omitempty"` - Diskiowrite int64 `json:"diskiowrite,omitempty"` - Diskkbsread int64 `json:"diskkbsread,omitempty"` - Diskkbswrite int64 `json:"diskkbswrite,omitempty"` - Diskofferingid string `json:"diskofferingid,omitempty"` - Diskofferingname string `json:"diskofferingname,omitempty"` - Displayname string `json:"displayname,omitempty"` - Displayvm bool `json:"displayvm,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"` - Group string `json:"group,omitempty"` - Groupid string `json:"groupid,omitempty"` - Guestosid string `json:"guestosid,omitempty"` - Haenable bool `json:"haenable,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Instancename string `json:"instancename,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isodisplaytext string `json:"isodisplaytext,omitempty"` - Isoid string `json:"isoid,omitempty"` - Isoname string `json:"isoname,omitempty"` - Keypair string `json:"keypair,omitempty"` - Memory int `json:"memory,omitempty"` - Name string `json:"name,omitempty"` - Networkkbsread int64 `json:"networkkbsread,omitempty"` - Networkkbswrite int64 `json:"networkkbswrite,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Ostypeid int64 `json:"ostypeid,omitempty"` - Password string `json:"password,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - Rootdeviceid int64 `json:"rootdeviceid,omitempty"` - Rootdevicetype string `json:"rootdevicetype,omitempty"` - Securitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Egressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"egressrule,omitempty"` - Id string `json:"id,omitempty"` - Ingressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"ingressrule,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinecount int `json:"virtualmachinecount,omitempty"` - Virtualmachineids []string `json:"virtualmachineids,omitempty"` - } `json:"securitygroup,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - Servicestate string `json:"servicestate,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatedisplaytext string `json:"templatedisplaytext,omitempty"` - Templateid string `json:"templateid,omitempty"` - Templatename string `json:"templatename,omitempty"` - Userid string `json:"userid,omitempty"` - Username string `json:"username,omitempty"` - Vgpu string `json:"vgpu,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/StoragePoolService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/StoragePoolService.go deleted file mode 100644 index 9b7b82c96fa..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/StoragePoolService.go +++ /dev/null @@ -1,300 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "net/url" - "strconv" -) - -type ListStorageProvidersParams struct { - p map[string]interface{} -} - -func (p *ListStorageProvidersParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["type"]; found { - u.Set("type", v.(string)) - } - return u -} - -func (p *ListStorageProvidersParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListStorageProvidersParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListStorageProvidersParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListStorageProvidersParams) SetType(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["storagePoolType"] = v - return -} - -// You should always use this function to get a new ListStorageProvidersParams instance, -// as then you are sure you have configured all required params -func (s *StoragePoolService) NewListStorageProvidersParams(storagePoolType string) *ListStorageProvidersParams { - p := &ListStorageProvidersParams{} - p.p = make(map[string]interface{}) - p.p["storagePoolType"] = storagePoolType - return p -} - -// Lists storage providers. -func (s *StoragePoolService) ListStorageProviders(p *ListStorageProvidersParams) (*ListStorageProvidersResponse, error) { - resp, err := s.cs.newRequest("listStorageProviders", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListStorageProvidersResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListStorageProvidersResponse struct { - Count int `json:"count"` - StorageProviders []*StorageProvider `json:"storageprovider"` -} - -type StorageProvider struct { - Name string `json:"name,omitempty"` - Type string `json:"type,omitempty"` -} - -type EnableStorageMaintenanceParams struct { - p map[string]interface{} -} - -func (p *EnableStorageMaintenanceParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *EnableStorageMaintenanceParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new EnableStorageMaintenanceParams instance, -// as then you are sure you have configured all required params -func (s *StoragePoolService) NewEnableStorageMaintenanceParams(id string) *EnableStorageMaintenanceParams { - p := &EnableStorageMaintenanceParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Puts storage pool into maintenance state -func (s *StoragePoolService) EnableStorageMaintenance(p *EnableStorageMaintenanceParams) (*EnableStorageMaintenanceResponse, error) { - resp, err := s.cs.newRequest("enableStorageMaintenance", p.toURLValues()) - if err != nil { - return nil, err - } - - var r EnableStorageMaintenanceResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type EnableStorageMaintenanceResponse struct { - JobID string `json:"jobid,omitempty"` - Capacityiops int64 `json:"capacityiops,omitempty"` - Clusterid string `json:"clusterid,omitempty"` - Clustername string `json:"clustername,omitempty"` - Created string `json:"created,omitempty"` - Disksizeallocated int64 `json:"disksizeallocated,omitempty"` - Disksizetotal int64 `json:"disksizetotal,omitempty"` - Disksizeused int64 `json:"disksizeused,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Name string `json:"name,omitempty"` - Overprovisionfactor string `json:"overprovisionfactor,omitempty"` - Path string `json:"path,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` - Scope string `json:"scope,omitempty"` - State string `json:"state,omitempty"` - Storagecapabilities map[string]string `json:"storagecapabilities,omitempty"` - Suitableformigration bool `json:"suitableformigration,omitempty"` - Tags string `json:"tags,omitempty"` - Type string `json:"type,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type CancelStorageMaintenanceParams struct { - p map[string]interface{} -} - -func (p *CancelStorageMaintenanceParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *CancelStorageMaintenanceParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new CancelStorageMaintenanceParams instance, -// as then you are sure you have configured all required params -func (s *StoragePoolService) NewCancelStorageMaintenanceParams(id string) *CancelStorageMaintenanceParams { - p := &CancelStorageMaintenanceParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Cancels maintenance for primary storage -func (s *StoragePoolService) CancelStorageMaintenance(p *CancelStorageMaintenanceParams) (*CancelStorageMaintenanceResponse, error) { - resp, err := s.cs.newRequest("cancelStorageMaintenance", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CancelStorageMaintenanceResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CancelStorageMaintenanceResponse struct { - JobID string `json:"jobid,omitempty"` - Capacityiops int64 `json:"capacityiops,omitempty"` - Clusterid string `json:"clusterid,omitempty"` - Clustername string `json:"clustername,omitempty"` - Created string `json:"created,omitempty"` - Disksizeallocated int64 `json:"disksizeallocated,omitempty"` - Disksizetotal int64 `json:"disksizetotal,omitempty"` - Disksizeused int64 `json:"disksizeused,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Name string `json:"name,omitempty"` - Overprovisionfactor string `json:"overprovisionfactor,omitempty"` - Path string `json:"path,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` - Scope string `json:"scope,omitempty"` - State string `json:"state,omitempty"` - Storagecapabilities map[string]string `json:"storagecapabilities,omitempty"` - Suitableformigration bool `json:"suitableformigration,omitempty"` - Tags string `json:"tags,omitempty"` - Type string `json:"type,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/StratosphereSSPService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/StratosphereSSPService.go deleted file mode 100644 index 4e638f84301..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/StratosphereSSPService.go +++ /dev/null @@ -1,132 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "net/url" -) - -type AddStratosphereSspParams struct { - p map[string]interface{} -} - -func (p *AddStratosphereSspParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["password"]; found { - u.Set("password", v.(string)) - } - if v, found := p.p["tenantuuid"]; found { - u.Set("tenantuuid", v.(string)) - } - if v, found := p.p["url"]; found { - u.Set("url", v.(string)) - } - if v, found := p.p["username"]; found { - u.Set("username", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *AddStratosphereSspParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *AddStratosphereSspParams) SetPassword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["password"] = v - return -} - -func (p *AddStratosphereSspParams) SetTenantuuid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tenantuuid"] = v - return -} - -func (p *AddStratosphereSspParams) SetUrl(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["url"] = v - return -} - -func (p *AddStratosphereSspParams) SetUsername(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["username"] = v - return -} - -func (p *AddStratosphereSspParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new AddStratosphereSspParams instance, -// as then you are sure you have configured all required params -func (s *StratosphereSSPService) NewAddStratosphereSspParams(name string, url string, zoneid string) *AddStratosphereSspParams { - p := &AddStratosphereSspParams{} - p.p = make(map[string]interface{}) - p.p["name"] = name - p.p["url"] = url - p.p["zoneid"] = zoneid - return p -} - -// Adds stratosphere ssp server -func (s *StratosphereSSPService) AddStratosphereSsp(p *AddStratosphereSspParams) (*AddStratosphereSspResponse, error) { - resp, err := s.cs.newRequest("addStratosphereSsp", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AddStratosphereSspResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type AddStratosphereSspResponse struct { - Hostid string `json:"hostid,omitempty"` - Name string `json:"name,omitempty"` - Url string `json:"url,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/SwiftService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/SwiftService.go deleted file mode 100644 index 72bcfc608fe..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/SwiftService.go +++ /dev/null @@ -1,249 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" -) - -type AddSwiftParams struct { - p map[string]interface{} -} - -func (p *AddSwiftParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["key"]; found { - u.Set("key", v.(string)) - } - if v, found := p.p["url"]; found { - u.Set("url", v.(string)) - } - if v, found := p.p["username"]; found { - u.Set("username", v.(string)) - } - return u -} - -func (p *AddSwiftParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *AddSwiftParams) SetKey(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["key"] = v - return -} - -func (p *AddSwiftParams) SetUrl(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["url"] = v - return -} - -func (p *AddSwiftParams) SetUsername(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["username"] = v - return -} - -// You should always use this function to get a new AddSwiftParams instance, -// as then you are sure you have configured all required params -func (s *SwiftService) NewAddSwiftParams(url string) *AddSwiftParams { - p := &AddSwiftParams{} - p.p = make(map[string]interface{}) - p.p["url"] = url - return p -} - -// Adds Swift. -func (s *SwiftService) AddSwift(p *AddSwiftParams) (*AddSwiftResponse, error) { - resp, err := s.cs.newRequest("addSwift", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AddSwiftResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type AddSwiftResponse struct { - Details []string `json:"details,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Protocol string `json:"protocol,omitempty"` - Providername string `json:"providername,omitempty"` - Scope string `json:"scope,omitempty"` - Url string `json:"url,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type ListSwiftsParams struct { - p map[string]interface{} -} - -func (p *ListSwiftsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("id", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - return u -} - -func (p *ListSwiftsParams) SetId(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListSwiftsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListSwiftsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListSwiftsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -// You should always use this function to get a new ListSwiftsParams instance, -// as then you are sure you have configured all required params -func (s *SwiftService) NewListSwiftsParams() *ListSwiftsParams { - p := &ListSwiftsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *SwiftService) GetSwiftID(keyword string, opts ...OptionFunc) (string, int, error) { - p := &ListSwiftsParams{} - p.p = make(map[string]interface{}) - - p.p["keyword"] = keyword - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListSwifts(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", keyword, l) - } - - if l.Count == 1 { - return l.Swifts[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.Swifts { - if v.Name == keyword { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l) -} - -// List Swift. -func (s *SwiftService) ListSwifts(p *ListSwiftsParams) (*ListSwiftsResponse, error) { - resp, err := s.cs.newRequest("listSwifts", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListSwiftsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListSwiftsResponse struct { - Count int `json:"count"` - Swifts []*Swift `json:"swift"` -} - -type Swift struct { - Details []string `json:"details,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Protocol string `json:"protocol,omitempty"` - Providername string `json:"providername,omitempty"` - Scope string `json:"scope,omitempty"` - Url string `json:"url,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/SystemCapacityService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/SystemCapacityService.go deleted file mode 100644 index 98444d65803..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/SystemCapacityService.go +++ /dev/null @@ -1,178 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "net/url" - "strconv" -) - -type ListCapacityParams struct { - p map[string]interface{} -} - -func (p *ListCapacityParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["clusterid"]; found { - u.Set("clusterid", v.(string)) - } - if v, found := p.p["fetchlatest"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fetchlatest", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["podid"]; found { - u.Set("podid", v.(string)) - } - if v, found := p.p["sortby"]; found { - u.Set("sortby", v.(string)) - } - if v, found := p.p["type"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("type", vv) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ListCapacityParams) SetClusterid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["clusterid"] = v - return -} - -func (p *ListCapacityParams) SetFetchlatest(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fetchlatest"] = v - return -} - -func (p *ListCapacityParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListCapacityParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListCapacityParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListCapacityParams) SetPodid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["podid"] = v - return -} - -func (p *ListCapacityParams) SetSortby(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["sortby"] = v - return -} - -func (p *ListCapacityParams) SetType(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["systemCapacityType"] = v - return -} - -func (p *ListCapacityParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ListCapacityParams instance, -// as then you are sure you have configured all required params -func (s *SystemCapacityService) NewListCapacityParams() *ListCapacityParams { - p := &ListCapacityParams{} - p.p = make(map[string]interface{}) - return p -} - -// Lists all the system wide capacities. -func (s *SystemCapacityService) ListCapacity(p *ListCapacityParams) (*ListCapacityResponse, error) { - resp, err := s.cs.newRequest("listCapacity", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListCapacityResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListCapacityResponse struct { - Count int `json:"count"` - Capacity []*Capacity `json:"capacity"` -} - -type Capacity struct { - Capacitytotal int64 `json:"capacitytotal,omitempty"` - Capacityused int64 `json:"capacityused,omitempty"` - Clusterid string `json:"clusterid,omitempty"` - Clustername string `json:"clustername,omitempty"` - Percentused string `json:"percentused,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` - Type int `json:"type,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/SystemVMService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/SystemVMService.go deleted file mode 100644 index 18b697a8569..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/SystemVMService.go +++ /dev/null @@ -1,1046 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type StartSystemVmParams struct { - p map[string]interface{} -} - -func (p *StartSystemVmParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *StartSystemVmParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new StartSystemVmParams instance, -// as then you are sure you have configured all required params -func (s *SystemVMService) NewStartSystemVmParams(id string) *StartSystemVmParams { - p := &StartSystemVmParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Starts a system virtual machine. -func (s *SystemVMService) StartSystemVm(p *StartSystemVmParams) (*StartSystemVmResponse, error) { - resp, err := s.cs.newRequest("startSystemVm", p.toURLValues()) - if err != nil { - return nil, err - } - - var r StartSystemVmResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type StartSystemVmResponse struct { - JobID string `json:"jobid,omitempty"` - Activeviewersessions int `json:"activeviewersessions,omitempty"` - Created string `json:"created,omitempty"` - Dns1 string `json:"dns1,omitempty"` - Dns2 string `json:"dns2,omitempty"` - Gateway string `json:"gateway,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Jobid string `json:"jobid,omitempty"` - Jobstatus int `json:"jobstatus,omitempty"` - Linklocalip string `json:"linklocalip,omitempty"` - Linklocalmacaddress string `json:"linklocalmacaddress,omitempty"` - Linklocalnetmask string `json:"linklocalnetmask,omitempty"` - Name string `json:"name,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Podid string `json:"podid,omitempty"` - Privateip string `json:"privateip,omitempty"` - Privatemacaddress string `json:"privatemacaddress,omitempty"` - Privatenetmask string `json:"privatenetmask,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicmacaddress string `json:"publicmacaddress,omitempty"` - Publicnetmask string `json:"publicnetmask,omitempty"` - State string `json:"state,omitempty"` - Systemvmtype string `json:"systemvmtype,omitempty"` - Templateid string `json:"templateid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type RebootSystemVmParams struct { - p map[string]interface{} -} - -func (p *RebootSystemVmParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *RebootSystemVmParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new RebootSystemVmParams instance, -// as then you are sure you have configured all required params -func (s *SystemVMService) NewRebootSystemVmParams(id string) *RebootSystemVmParams { - p := &RebootSystemVmParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Reboots a system VM. -func (s *SystemVMService) RebootSystemVm(p *RebootSystemVmParams) (*RebootSystemVmResponse, error) { - resp, err := s.cs.newRequest("rebootSystemVm", p.toURLValues()) - if err != nil { - return nil, err - } - - var r RebootSystemVmResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type RebootSystemVmResponse struct { - JobID string `json:"jobid,omitempty"` - Activeviewersessions int `json:"activeviewersessions,omitempty"` - Created string `json:"created,omitempty"` - Dns1 string `json:"dns1,omitempty"` - Dns2 string `json:"dns2,omitempty"` - Gateway string `json:"gateway,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Jobid string `json:"jobid,omitempty"` - Jobstatus int `json:"jobstatus,omitempty"` - Linklocalip string `json:"linklocalip,omitempty"` - Linklocalmacaddress string `json:"linklocalmacaddress,omitempty"` - Linklocalnetmask string `json:"linklocalnetmask,omitempty"` - Name string `json:"name,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Podid string `json:"podid,omitempty"` - Privateip string `json:"privateip,omitempty"` - Privatemacaddress string `json:"privatemacaddress,omitempty"` - Privatenetmask string `json:"privatenetmask,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicmacaddress string `json:"publicmacaddress,omitempty"` - Publicnetmask string `json:"publicnetmask,omitempty"` - State string `json:"state,omitempty"` - Systemvmtype string `json:"systemvmtype,omitempty"` - Templateid string `json:"templateid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type StopSystemVmParams struct { - p map[string]interface{} -} - -func (p *StopSystemVmParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["forced"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("forced", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *StopSystemVmParams) SetForced(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["forced"] = v - return -} - -func (p *StopSystemVmParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new StopSystemVmParams instance, -// as then you are sure you have configured all required params -func (s *SystemVMService) NewStopSystemVmParams(id string) *StopSystemVmParams { - p := &StopSystemVmParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Stops a system VM. -func (s *SystemVMService) StopSystemVm(p *StopSystemVmParams) (*StopSystemVmResponse, error) { - resp, err := s.cs.newRequest("stopSystemVm", p.toURLValues()) - if err != nil { - return nil, err - } - - var r StopSystemVmResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type StopSystemVmResponse struct { - JobID string `json:"jobid,omitempty"` - Activeviewersessions int `json:"activeviewersessions,omitempty"` - Created string `json:"created,omitempty"` - Dns1 string `json:"dns1,omitempty"` - Dns2 string `json:"dns2,omitempty"` - Gateway string `json:"gateway,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Jobid string `json:"jobid,omitempty"` - Jobstatus int `json:"jobstatus,omitempty"` - Linklocalip string `json:"linklocalip,omitempty"` - Linklocalmacaddress string `json:"linklocalmacaddress,omitempty"` - Linklocalnetmask string `json:"linklocalnetmask,omitempty"` - Name string `json:"name,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Podid string `json:"podid,omitempty"` - Privateip string `json:"privateip,omitempty"` - Privatemacaddress string `json:"privatemacaddress,omitempty"` - Privatenetmask string `json:"privatenetmask,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicmacaddress string `json:"publicmacaddress,omitempty"` - Publicnetmask string `json:"publicnetmask,omitempty"` - State string `json:"state,omitempty"` - Systemvmtype string `json:"systemvmtype,omitempty"` - Templateid string `json:"templateid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type DestroySystemVmParams struct { - p map[string]interface{} -} - -func (p *DestroySystemVmParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DestroySystemVmParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DestroySystemVmParams instance, -// as then you are sure you have configured all required params -func (s *SystemVMService) NewDestroySystemVmParams(id string) *DestroySystemVmParams { - p := &DestroySystemVmParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Destroyes a system virtual machine. -func (s *SystemVMService) DestroySystemVm(p *DestroySystemVmParams) (*DestroySystemVmResponse, error) { - resp, err := s.cs.newRequest("destroySystemVm", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DestroySystemVmResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DestroySystemVmResponse struct { - JobID string `json:"jobid,omitempty"` - Activeviewersessions int `json:"activeviewersessions,omitempty"` - Created string `json:"created,omitempty"` - Dns1 string `json:"dns1,omitempty"` - Dns2 string `json:"dns2,omitempty"` - Gateway string `json:"gateway,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Jobid string `json:"jobid,omitempty"` - Jobstatus int `json:"jobstatus,omitempty"` - Linklocalip string `json:"linklocalip,omitempty"` - Linklocalmacaddress string `json:"linklocalmacaddress,omitempty"` - Linklocalnetmask string `json:"linklocalnetmask,omitempty"` - Name string `json:"name,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Podid string `json:"podid,omitempty"` - Privateip string `json:"privateip,omitempty"` - Privatemacaddress string `json:"privatemacaddress,omitempty"` - Privatenetmask string `json:"privatenetmask,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicmacaddress string `json:"publicmacaddress,omitempty"` - Publicnetmask string `json:"publicnetmask,omitempty"` - State string `json:"state,omitempty"` - Systemvmtype string `json:"systemvmtype,omitempty"` - Templateid string `json:"templateid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type ListSystemVmsParams struct { - p map[string]interface{} -} - -func (p *ListSystemVmsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["hostid"]; found { - u.Set("hostid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["podid"]; found { - u.Set("podid", v.(string)) - } - if v, found := p.p["state"]; found { - u.Set("state", v.(string)) - } - if v, found := p.p["storageid"]; found { - u.Set("storageid", v.(string)) - } - if v, found := p.p["systemvmtype"]; found { - u.Set("systemvmtype", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ListSystemVmsParams) SetHostid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hostid"] = v - return -} - -func (p *ListSystemVmsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListSystemVmsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListSystemVmsParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListSystemVmsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListSystemVmsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListSystemVmsParams) SetPodid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["podid"] = v - return -} - -func (p *ListSystemVmsParams) SetState(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["state"] = v - return -} - -func (p *ListSystemVmsParams) SetStorageid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["storageid"] = v - return -} - -func (p *ListSystemVmsParams) SetSystemvmtype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["systemvmtype"] = v - return -} - -func (p *ListSystemVmsParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ListSystemVmsParams instance, -// as then you are sure you have configured all required params -func (s *SystemVMService) NewListSystemVmsParams() *ListSystemVmsParams { - p := &ListSystemVmsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *SystemVMService) GetSystemVmID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListSystemVmsParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListSystemVms(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.SystemVms[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.SystemVms { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *SystemVMService) GetSystemVmByName(name string, opts ...OptionFunc) (*SystemVm, int, error) { - id, count, err := s.GetSystemVmID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetSystemVmByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *SystemVMService) GetSystemVmByID(id string, opts ...OptionFunc) (*SystemVm, int, error) { - p := &ListSystemVmsParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListSystemVms(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.SystemVms[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for SystemVm UUID: %s!", id) -} - -// List system virtual machines. -func (s *SystemVMService) ListSystemVms(p *ListSystemVmsParams) (*ListSystemVmsResponse, error) { - resp, err := s.cs.newRequest("listSystemVms", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListSystemVmsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListSystemVmsResponse struct { - Count int `json:"count"` - SystemVms []*SystemVm `json:"systemvm"` -} - -type SystemVm struct { - Activeviewersessions int `json:"activeviewersessions,omitempty"` - Created string `json:"created,omitempty"` - Dns1 string `json:"dns1,omitempty"` - Dns2 string `json:"dns2,omitempty"` - Gateway string `json:"gateway,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Jobid string `json:"jobid,omitempty"` - Jobstatus int `json:"jobstatus,omitempty"` - Linklocalip string `json:"linklocalip,omitempty"` - Linklocalmacaddress string `json:"linklocalmacaddress,omitempty"` - Linklocalnetmask string `json:"linklocalnetmask,omitempty"` - Name string `json:"name,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Podid string `json:"podid,omitempty"` - Privateip string `json:"privateip,omitempty"` - Privatemacaddress string `json:"privatemacaddress,omitempty"` - Privatenetmask string `json:"privatenetmask,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicmacaddress string `json:"publicmacaddress,omitempty"` - Publicnetmask string `json:"publicnetmask,omitempty"` - State string `json:"state,omitempty"` - Systemvmtype string `json:"systemvmtype,omitempty"` - Templateid string `json:"templateid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type MigrateSystemVmParams struct { - p map[string]interface{} -} - -func (p *MigrateSystemVmParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["hostid"]; found { - u.Set("hostid", v.(string)) - } - if v, found := p.p["virtualmachineid"]; found { - u.Set("virtualmachineid", v.(string)) - } - return u -} - -func (p *MigrateSystemVmParams) SetHostid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hostid"] = v - return -} - -func (p *MigrateSystemVmParams) SetVirtualmachineid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["virtualmachineid"] = v - return -} - -// You should always use this function to get a new MigrateSystemVmParams instance, -// as then you are sure you have configured all required params -func (s *SystemVMService) NewMigrateSystemVmParams(hostid string, virtualmachineid string) *MigrateSystemVmParams { - p := &MigrateSystemVmParams{} - p.p = make(map[string]interface{}) - p.p["hostid"] = hostid - p.p["virtualmachineid"] = virtualmachineid - return p -} - -// Attempts Migration of a system virtual machine to the host specified. -func (s *SystemVMService) MigrateSystemVm(p *MigrateSystemVmParams) (*MigrateSystemVmResponse, error) { - resp, err := s.cs.newRequest("migrateSystemVm", p.toURLValues()) - if err != nil { - return nil, err - } - - var r MigrateSystemVmResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type MigrateSystemVmResponse struct { - JobID string `json:"jobid,omitempty"` - Activeviewersessions int `json:"activeviewersessions,omitempty"` - Created string `json:"created,omitempty"` - Dns1 string `json:"dns1,omitempty"` - Dns2 string `json:"dns2,omitempty"` - Gateway string `json:"gateway,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Jobid string `json:"jobid,omitempty"` - Jobstatus int `json:"jobstatus,omitempty"` - Linklocalip string `json:"linklocalip,omitempty"` - Linklocalmacaddress string `json:"linklocalmacaddress,omitempty"` - Linklocalnetmask string `json:"linklocalnetmask,omitempty"` - Name string `json:"name,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Podid string `json:"podid,omitempty"` - Privateip string `json:"privateip,omitempty"` - Privatemacaddress string `json:"privatemacaddress,omitempty"` - Privatenetmask string `json:"privatenetmask,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicmacaddress string `json:"publicmacaddress,omitempty"` - Publicnetmask string `json:"publicnetmask,omitempty"` - State string `json:"state,omitempty"` - Systemvmtype string `json:"systemvmtype,omitempty"` - Templateid string `json:"templateid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type ChangeServiceForSystemVmParams struct { - p map[string]interface{} -} - -func (p *ChangeServiceForSystemVmParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["details"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("details[%d].key", i), k) - u.Set(fmt.Sprintf("details[%d].value", i), vv) - i++ - } - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["serviceofferingid"]; found { - u.Set("serviceofferingid", v.(string)) - } - return u -} - -func (p *ChangeServiceForSystemVmParams) SetDetails(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["details"] = v - return -} - -func (p *ChangeServiceForSystemVmParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ChangeServiceForSystemVmParams) SetServiceofferingid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["serviceofferingid"] = v - return -} - -// You should always use this function to get a new ChangeServiceForSystemVmParams instance, -// as then you are sure you have configured all required params -func (s *SystemVMService) NewChangeServiceForSystemVmParams(id string, serviceofferingid string) *ChangeServiceForSystemVmParams { - p := &ChangeServiceForSystemVmParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - p.p["serviceofferingid"] = serviceofferingid - return p -} - -// Changes the service offering for a system vm (console proxy or secondary storage). The system vm must be in a "Stopped" state for this command to take effect. -func (s *SystemVMService) ChangeServiceForSystemVm(p *ChangeServiceForSystemVmParams) (*ChangeServiceForSystemVmResponse, error) { - resp, err := s.cs.newRequest("changeServiceForSystemVm", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ChangeServiceForSystemVmResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ChangeServiceForSystemVmResponse struct { - Activeviewersessions int `json:"activeviewersessions,omitempty"` - Created string `json:"created,omitempty"` - Dns1 string `json:"dns1,omitempty"` - Dns2 string `json:"dns2,omitempty"` - Gateway string `json:"gateway,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Jobid string `json:"jobid,omitempty"` - Jobstatus int `json:"jobstatus,omitempty"` - Linklocalip string `json:"linklocalip,omitempty"` - Linklocalmacaddress string `json:"linklocalmacaddress,omitempty"` - Linklocalnetmask string `json:"linklocalnetmask,omitempty"` - Name string `json:"name,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Podid string `json:"podid,omitempty"` - Privateip string `json:"privateip,omitempty"` - Privatemacaddress string `json:"privatemacaddress,omitempty"` - Privatenetmask string `json:"privatenetmask,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicmacaddress string `json:"publicmacaddress,omitempty"` - Publicnetmask string `json:"publicnetmask,omitempty"` - State string `json:"state,omitempty"` - Systemvmtype string `json:"systemvmtype,omitempty"` - Templateid string `json:"templateid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type ScaleSystemVmParams struct { - p map[string]interface{} -} - -func (p *ScaleSystemVmParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["details"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("details[%d].key", i), k) - u.Set(fmt.Sprintf("details[%d].value", i), vv) - i++ - } - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["serviceofferingid"]; found { - u.Set("serviceofferingid", v.(string)) - } - return u -} - -func (p *ScaleSystemVmParams) SetDetails(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["details"] = v - return -} - -func (p *ScaleSystemVmParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ScaleSystemVmParams) SetServiceofferingid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["serviceofferingid"] = v - return -} - -// You should always use this function to get a new ScaleSystemVmParams instance, -// as then you are sure you have configured all required params -func (s *SystemVMService) NewScaleSystemVmParams(id string, serviceofferingid string) *ScaleSystemVmParams { - p := &ScaleSystemVmParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - p.p["serviceofferingid"] = serviceofferingid - return p -} - -// Scale the service offering for a system vm (console proxy or secondary storage). The system vm must be in a "Stopped" state for this command to take effect. -func (s *SystemVMService) ScaleSystemVm(p *ScaleSystemVmParams) (*ScaleSystemVmResponse, error) { - resp, err := s.cs.newRequest("scaleSystemVm", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ScaleSystemVmResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type ScaleSystemVmResponse struct { - JobID string `json:"jobid,omitempty"` - Activeviewersessions int `json:"activeviewersessions,omitempty"` - Created string `json:"created,omitempty"` - Dns1 string `json:"dns1,omitempty"` - Dns2 string `json:"dns2,omitempty"` - Gateway string `json:"gateway,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Jobid string `json:"jobid,omitempty"` - Jobstatus int `json:"jobstatus,omitempty"` - Linklocalip string `json:"linklocalip,omitempty"` - Linklocalmacaddress string `json:"linklocalmacaddress,omitempty"` - Linklocalnetmask string `json:"linklocalnetmask,omitempty"` - Name string `json:"name,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Podid string `json:"podid,omitempty"` - Privateip string `json:"privateip,omitempty"` - Privatemacaddress string `json:"privatemacaddress,omitempty"` - Privatenetmask string `json:"privatenetmask,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicmacaddress string `json:"publicmacaddress,omitempty"` - Publicnetmask string `json:"publicnetmask,omitempty"` - State string `json:"state,omitempty"` - Systemvmtype string `json:"systemvmtype,omitempty"` - Templateid string `json:"templateid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/TemplateService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/TemplateService.go deleted file mode 100644 index 30498c7c615..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/TemplateService.go +++ /dev/null @@ -1,2318 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type CreateTemplateParams struct { - p map[string]interface{} -} - -func (p *CreateTemplateParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["bits"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("bits", vv) - } - if v, found := p.p["details"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("details[%d].key", i), k) - u.Set(fmt.Sprintf("details[%d].value", i), vv) - i++ - } - } - if v, found := p.p["displaytext"]; found { - u.Set("displaytext", v.(string)) - } - if v, found := p.p["isdynamicallyscalable"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isdynamicallyscalable", vv) - } - if v, found := p.p["isfeatured"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isfeatured", vv) - } - if v, found := p.p["ispublic"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("ispublic", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["ostypeid"]; found { - u.Set("ostypeid", v.(string)) - } - if v, found := p.p["passwordenabled"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("passwordenabled", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["requireshvm"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("requireshvm", vv) - } - if v, found := p.p["snapshotid"]; found { - u.Set("snapshotid", v.(string)) - } - if v, found := p.p["templatetag"]; found { - u.Set("templatetag", v.(string)) - } - if v, found := p.p["url"]; found { - u.Set("url", v.(string)) - } - if v, found := p.p["virtualmachineid"]; found { - u.Set("virtualmachineid", v.(string)) - } - if v, found := p.p["volumeid"]; found { - u.Set("volumeid", v.(string)) - } - return u -} - -func (p *CreateTemplateParams) SetBits(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["bits"] = v - return -} - -func (p *CreateTemplateParams) SetDetails(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["details"] = v - return -} - -func (p *CreateTemplateParams) SetDisplaytext(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displaytext"] = v - return -} - -func (p *CreateTemplateParams) SetIsdynamicallyscalable(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isdynamicallyscalable"] = v - return -} - -func (p *CreateTemplateParams) SetIsfeatured(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isfeatured"] = v - return -} - -func (p *CreateTemplateParams) SetIspublic(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ispublic"] = v - return -} - -func (p *CreateTemplateParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *CreateTemplateParams) SetOstypeid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ostypeid"] = v - return -} - -func (p *CreateTemplateParams) SetPasswordenabled(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["passwordenabled"] = v - return -} - -func (p *CreateTemplateParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *CreateTemplateParams) SetRequireshvm(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["requireshvm"] = v - return -} - -func (p *CreateTemplateParams) SetSnapshotid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["snapshotid"] = v - return -} - -func (p *CreateTemplateParams) SetTemplatetag(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["templatetag"] = v - return -} - -func (p *CreateTemplateParams) SetUrl(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["url"] = v - return -} - -func (p *CreateTemplateParams) SetVirtualmachineid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["virtualmachineid"] = v - return -} - -func (p *CreateTemplateParams) SetVolumeid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["volumeid"] = v - return -} - -// You should always use this function to get a new CreateTemplateParams instance, -// as then you are sure you have configured all required params -func (s *TemplateService) NewCreateTemplateParams(displaytext string, name string, ostypeid string) *CreateTemplateParams { - p := &CreateTemplateParams{} - p.p = make(map[string]interface{}) - p.p["displaytext"] = displaytext - p.p["name"] = name - p.p["ostypeid"] = ostypeid - return p -} - -// Creates a template of a virtual machine. The virtual machine must be in a STOPPED state. A template created from this command is automatically designated as a private template visible to the account that created it. -func (s *TemplateService) CreateTemplate(p *CreateTemplateParams) (*CreateTemplateResponse, error) { - resp, err := s.cs.newRequest("createTemplate", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateTemplateResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateTemplateResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Accountid string `json:"accountid,omitempty"` - Bootable bool `json:"bootable,omitempty"` - Checksum string `json:"checksum,omitempty"` - Created string `json:"created,omitempty"` - CrossZones bool `json:"crossZones,omitempty"` - Details map[string]string `json:"details,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Format string `json:"format,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isextractable bool `json:"isextractable,omitempty"` - Isfeatured bool `json:"isfeatured,omitempty"` - Ispublic bool `json:"ispublic,omitempty"` - Isready bool `json:"isready,omitempty"` - Name string `json:"name,omitempty"` - Ostypeid string `json:"ostypeid,omitempty"` - Ostypename string `json:"ostypename,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Removed string `json:"removed,omitempty"` - Size int64 `json:"size,omitempty"` - Sourcetemplateid string `json:"sourcetemplateid,omitempty"` - Sshkeyenabled bool `json:"sshkeyenabled,omitempty"` - Status string `json:"status,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatetag string `json:"templatetag,omitempty"` - Templatetype string `json:"templatetype,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type RegisterTemplateParams struct { - p map[string]interface{} -} - -func (p *RegisterTemplateParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["bits"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("bits", vv) - } - if v, found := p.p["checksum"]; found { - u.Set("checksum", v.(string)) - } - if v, found := p.p["details"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("details[%d].key", i), k) - u.Set(fmt.Sprintf("details[%d].value", i), vv) - i++ - } - } - if v, found := p.p["displaytext"]; found { - u.Set("displaytext", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["format"]; found { - u.Set("format", v.(string)) - } - if v, found := p.p["hypervisor"]; found { - u.Set("hypervisor", v.(string)) - } - if v, found := p.p["isdynamicallyscalable"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isdynamicallyscalable", vv) - } - if v, found := p.p["isextractable"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isextractable", vv) - } - if v, found := p.p["isfeatured"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isfeatured", vv) - } - if v, found := p.p["ispublic"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("ispublic", vv) - } - if v, found := p.p["isrouting"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrouting", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["ostypeid"]; found { - u.Set("ostypeid", v.(string)) - } - if v, found := p.p["passwordenabled"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("passwordenabled", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["requireshvm"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("requireshvm", vv) - } - if v, found := p.p["sshkeyenabled"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("sshkeyenabled", vv) - } - if v, found := p.p["templatetag"]; found { - u.Set("templatetag", v.(string)) - } - if v, found := p.p["url"]; found { - u.Set("url", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *RegisterTemplateParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *RegisterTemplateParams) SetBits(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["bits"] = v - return -} - -func (p *RegisterTemplateParams) SetChecksum(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["checksum"] = v - return -} - -func (p *RegisterTemplateParams) SetDetails(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["details"] = v - return -} - -func (p *RegisterTemplateParams) SetDisplaytext(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displaytext"] = v - return -} - -func (p *RegisterTemplateParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *RegisterTemplateParams) SetFormat(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["format"] = v - return -} - -func (p *RegisterTemplateParams) SetHypervisor(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hypervisor"] = v - return -} - -func (p *RegisterTemplateParams) SetIsdynamicallyscalable(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isdynamicallyscalable"] = v - return -} - -func (p *RegisterTemplateParams) SetIsextractable(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isextractable"] = v - return -} - -func (p *RegisterTemplateParams) SetIsfeatured(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isfeatured"] = v - return -} - -func (p *RegisterTemplateParams) SetIspublic(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ispublic"] = v - return -} - -func (p *RegisterTemplateParams) SetIsrouting(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrouting"] = v - return -} - -func (p *RegisterTemplateParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *RegisterTemplateParams) SetOstypeid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ostypeid"] = v - return -} - -func (p *RegisterTemplateParams) SetPasswordenabled(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["passwordenabled"] = v - return -} - -func (p *RegisterTemplateParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *RegisterTemplateParams) SetRequireshvm(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["requireshvm"] = v - return -} - -func (p *RegisterTemplateParams) SetSshkeyenabled(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["sshkeyenabled"] = v - return -} - -func (p *RegisterTemplateParams) SetTemplatetag(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["templatetag"] = v - return -} - -func (p *RegisterTemplateParams) SetUrl(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["url"] = v - return -} - -func (p *RegisterTemplateParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new RegisterTemplateParams instance, -// as then you are sure you have configured all required params -func (s *TemplateService) NewRegisterTemplateParams(displaytext string, format string, hypervisor string, name string, ostypeid string, url string, zoneid string) *RegisterTemplateParams { - p := &RegisterTemplateParams{} - p.p = make(map[string]interface{}) - p.p["displaytext"] = displaytext - p.p["format"] = format - p.p["hypervisor"] = hypervisor - p.p["name"] = name - p.p["ostypeid"] = ostypeid - p.p["url"] = url - p.p["zoneid"] = zoneid - return p -} - -// Registers an existing template into the CloudStack cloud. -func (s *TemplateService) RegisterTemplate(p *RegisterTemplateParams) (*RegisterTemplateResponse, error) { - resp, err := s.cs.newRequest("registerTemplate", p.toURLValues()) - if err != nil { - return nil, err - } - - var r RegisterTemplateResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type RegisterTemplateResponse struct { - Count int `json:"count"` - RegisterTemplate []*RegisterTemplate `json:"template"` -} - -type RegisterTemplate struct { - Account string `json:"account,omitempty"` - Accountid string `json:"accountid,omitempty"` - Bootable bool `json:"bootable,omitempty"` - Checksum string `json:"checksum,omitempty"` - Created string `json:"created,omitempty"` - CrossZones bool `json:"crossZones,omitempty"` - Details map[string]string `json:"details,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Format string `json:"format,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isextractable bool `json:"isextractable,omitempty"` - Isfeatured bool `json:"isfeatured,omitempty"` - Ispublic bool `json:"ispublic,omitempty"` - Isready bool `json:"isready,omitempty"` - Name string `json:"name,omitempty"` - Ostypeid string `json:"ostypeid,omitempty"` - Ostypename string `json:"ostypename,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Removed string `json:"removed,omitempty"` - Size int64 `json:"size,omitempty"` - Sourcetemplateid string `json:"sourcetemplateid,omitempty"` - Sshkeyenabled bool `json:"sshkeyenabled,omitempty"` - Status string `json:"status,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatetag string `json:"templatetag,omitempty"` - Templatetype string `json:"templatetype,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type UpdateTemplateParams struct { - p map[string]interface{} -} - -func (p *UpdateTemplateParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["bootable"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("bootable", vv) - } - if v, found := p.p["details"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("details[%d].key", i), k) - u.Set(fmt.Sprintf("details[%d].value", i), vv) - i++ - } - } - if v, found := p.p["displaytext"]; found { - u.Set("displaytext", v.(string)) - } - if v, found := p.p["format"]; found { - u.Set("format", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isdynamicallyscalable"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isdynamicallyscalable", vv) - } - if v, found := p.p["isrouting"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrouting", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["ostypeid"]; found { - u.Set("ostypeid", v.(string)) - } - if v, found := p.p["passwordenabled"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("passwordenabled", vv) - } - if v, found := p.p["requireshvm"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("requireshvm", vv) - } - if v, found := p.p["sortkey"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("sortkey", vv) - } - return u -} - -func (p *UpdateTemplateParams) SetBootable(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["bootable"] = v - return -} - -func (p *UpdateTemplateParams) SetDetails(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["details"] = v - return -} - -func (p *UpdateTemplateParams) SetDisplaytext(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displaytext"] = v - return -} - -func (p *UpdateTemplateParams) SetFormat(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["format"] = v - return -} - -func (p *UpdateTemplateParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateTemplateParams) SetIsdynamicallyscalable(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isdynamicallyscalable"] = v - return -} - -func (p *UpdateTemplateParams) SetIsrouting(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrouting"] = v - return -} - -func (p *UpdateTemplateParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *UpdateTemplateParams) SetOstypeid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ostypeid"] = v - return -} - -func (p *UpdateTemplateParams) SetPasswordenabled(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["passwordenabled"] = v - return -} - -func (p *UpdateTemplateParams) SetRequireshvm(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["requireshvm"] = v - return -} - -func (p *UpdateTemplateParams) SetSortkey(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["sortkey"] = v - return -} - -// You should always use this function to get a new UpdateTemplateParams instance, -// as then you are sure you have configured all required params -func (s *TemplateService) NewUpdateTemplateParams(id string) *UpdateTemplateParams { - p := &UpdateTemplateParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates attributes of a template. -func (s *TemplateService) UpdateTemplate(p *UpdateTemplateParams) (*UpdateTemplateResponse, error) { - resp, err := s.cs.newRequest("updateTemplate", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateTemplateResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type UpdateTemplateResponse struct { - Account string `json:"account,omitempty"` - Accountid string `json:"accountid,omitempty"` - Bootable bool `json:"bootable,omitempty"` - Checksum string `json:"checksum,omitempty"` - Created string `json:"created,omitempty"` - CrossZones bool `json:"crossZones,omitempty"` - Details map[string]string `json:"details,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Format string `json:"format,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isextractable bool `json:"isextractable,omitempty"` - Isfeatured bool `json:"isfeatured,omitempty"` - Ispublic bool `json:"ispublic,omitempty"` - Isready bool `json:"isready,omitempty"` - Name string `json:"name,omitempty"` - Ostypeid string `json:"ostypeid,omitempty"` - Ostypename string `json:"ostypename,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Removed string `json:"removed,omitempty"` - Size int64 `json:"size,omitempty"` - Sourcetemplateid string `json:"sourcetemplateid,omitempty"` - Sshkeyenabled bool `json:"sshkeyenabled,omitempty"` - Status string `json:"status,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatetag string `json:"templatetag,omitempty"` - Templatetype string `json:"templatetype,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type CopyTemplateParams struct { - p map[string]interface{} -} - -func (p *CopyTemplateParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["destzoneid"]; found { - u.Set("destzoneid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["sourcezoneid"]; found { - u.Set("sourcezoneid", v.(string)) - } - return u -} - -func (p *CopyTemplateParams) SetDestzoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["destzoneid"] = v - return -} - -func (p *CopyTemplateParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *CopyTemplateParams) SetSourcezoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["sourcezoneid"] = v - return -} - -// You should always use this function to get a new CopyTemplateParams instance, -// as then you are sure you have configured all required params -func (s *TemplateService) NewCopyTemplateParams(destzoneid string, id string) *CopyTemplateParams { - p := &CopyTemplateParams{} - p.p = make(map[string]interface{}) - p.p["destzoneid"] = destzoneid - p.p["id"] = id - return p -} - -// Copies a template from one zone to another. -func (s *TemplateService) CopyTemplate(p *CopyTemplateParams) (*CopyTemplateResponse, error) { - resp, err := s.cs.newRequest("copyTemplate", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CopyTemplateResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CopyTemplateResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Accountid string `json:"accountid,omitempty"` - Bootable bool `json:"bootable,omitempty"` - Checksum string `json:"checksum,omitempty"` - Created string `json:"created,omitempty"` - CrossZones bool `json:"crossZones,omitempty"` - Details map[string]string `json:"details,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Format string `json:"format,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isextractable bool `json:"isextractable,omitempty"` - Isfeatured bool `json:"isfeatured,omitempty"` - Ispublic bool `json:"ispublic,omitempty"` - Isready bool `json:"isready,omitempty"` - Name string `json:"name,omitempty"` - Ostypeid string `json:"ostypeid,omitempty"` - Ostypename string `json:"ostypename,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Removed string `json:"removed,omitempty"` - Size int64 `json:"size,omitempty"` - Sourcetemplateid string `json:"sourcetemplateid,omitempty"` - Sshkeyenabled bool `json:"sshkeyenabled,omitempty"` - Status string `json:"status,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatetag string `json:"templatetag,omitempty"` - Templatetype string `json:"templatetype,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type DeleteTemplateParams struct { - p map[string]interface{} -} - -func (p *DeleteTemplateParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *DeleteTemplateParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *DeleteTemplateParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new DeleteTemplateParams instance, -// as then you are sure you have configured all required params -func (s *TemplateService) NewDeleteTemplateParams(id string) *DeleteTemplateParams { - p := &DeleteTemplateParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a template from the system. All virtual machines using the deleted template will not be affected. -func (s *TemplateService) DeleteTemplate(p *DeleteTemplateParams) (*DeleteTemplateResponse, error) { - resp, err := s.cs.newRequest("deleteTemplate", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteTemplateResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteTemplateResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListTemplatesParams struct { - p map[string]interface{} -} - -func (p *ListTemplatesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["hypervisor"]; found { - u.Set("hypervisor", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["showremoved"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("showremoved", vv) - } - if v, found := p.p["tags"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("tags[%d].key", i), k) - u.Set(fmt.Sprintf("tags[%d].value", i), vv) - i++ - } - } - if v, found := p.p["templatefilter"]; found { - u.Set("templatefilter", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ListTemplatesParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListTemplatesParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListTemplatesParams) SetHypervisor(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hypervisor"] = v - return -} - -func (p *ListTemplatesParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListTemplatesParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListTemplatesParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListTemplatesParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListTemplatesParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListTemplatesParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListTemplatesParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListTemplatesParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListTemplatesParams) SetShowremoved(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["showremoved"] = v - return -} - -func (p *ListTemplatesParams) SetTags(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tags"] = v - return -} - -func (p *ListTemplatesParams) SetTemplatefilter(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["templatefilter"] = v - return -} - -func (p *ListTemplatesParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ListTemplatesParams instance, -// as then you are sure you have configured all required params -func (s *TemplateService) NewListTemplatesParams(templatefilter string) *ListTemplatesParams { - p := &ListTemplatesParams{} - p.p = make(map[string]interface{}) - p.p["templatefilter"] = templatefilter - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *TemplateService) GetTemplateID(name string, templatefilter string, zoneid string, opts ...OptionFunc) (string, int, error) { - p := &ListTemplatesParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - p.p["templatefilter"] = templatefilter - p.p["zoneid"] = zoneid - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListTemplates(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.Templates[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.Templates { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *TemplateService) GetTemplateByName(name string, templatefilter string, zoneid string, opts ...OptionFunc) (*Template, int, error) { - id, count, err := s.GetTemplateID(name, templatefilter, zoneid, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetTemplateByID(id, templatefilter, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *TemplateService) GetTemplateByID(id string, templatefilter string, opts ...OptionFunc) (*Template, int, error) { - p := &ListTemplatesParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - p.p["templatefilter"] = templatefilter - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListTemplates(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.Templates[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for Template UUID: %s!", id) -} - -// List all public, private, and privileged templates. -func (s *TemplateService) ListTemplates(p *ListTemplatesParams) (*ListTemplatesResponse, error) { - resp, err := s.cs.newRequest("listTemplates", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListTemplatesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListTemplatesResponse struct { - Count int `json:"count"` - Templates []*Template `json:"template"` -} - -type Template struct { - Account string `json:"account,omitempty"` - Accountid string `json:"accountid,omitempty"` - Bootable bool `json:"bootable,omitempty"` - Checksum string `json:"checksum,omitempty"` - Created string `json:"created,omitempty"` - CrossZones bool `json:"crossZones,omitempty"` - Details map[string]string `json:"details,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Format string `json:"format,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isextractable bool `json:"isextractable,omitempty"` - Isfeatured bool `json:"isfeatured,omitempty"` - Ispublic bool `json:"ispublic,omitempty"` - Isready bool `json:"isready,omitempty"` - Name string `json:"name,omitempty"` - Ostypeid string `json:"ostypeid,omitempty"` - Ostypename string `json:"ostypename,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Removed string `json:"removed,omitempty"` - Size int64 `json:"size,omitempty"` - Sourcetemplateid string `json:"sourcetemplateid,omitempty"` - Sshkeyenabled bool `json:"sshkeyenabled,omitempty"` - Status string `json:"status,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatetag string `json:"templatetag,omitempty"` - Templatetype string `json:"templatetype,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type UpdateTemplatePermissionsParams struct { - p map[string]interface{} -} - -func (p *UpdateTemplatePermissionsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["accounts"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("accounts", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isextractable"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isextractable", vv) - } - if v, found := p.p["isfeatured"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isfeatured", vv) - } - if v, found := p.p["ispublic"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("ispublic", vv) - } - if v, found := p.p["op"]; found { - u.Set("op", v.(string)) - } - if v, found := p.p["projectids"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("projectids", vv) - } - return u -} - -func (p *UpdateTemplatePermissionsParams) SetAccounts(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["accounts"] = v - return -} - -func (p *UpdateTemplatePermissionsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateTemplatePermissionsParams) SetIsextractable(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isextractable"] = v - return -} - -func (p *UpdateTemplatePermissionsParams) SetIsfeatured(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isfeatured"] = v - return -} - -func (p *UpdateTemplatePermissionsParams) SetIspublic(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ispublic"] = v - return -} - -func (p *UpdateTemplatePermissionsParams) SetOp(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["op"] = v - return -} - -func (p *UpdateTemplatePermissionsParams) SetProjectids(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectids"] = v - return -} - -// You should always use this function to get a new UpdateTemplatePermissionsParams instance, -// as then you are sure you have configured all required params -func (s *TemplateService) NewUpdateTemplatePermissionsParams(id string) *UpdateTemplatePermissionsParams { - p := &UpdateTemplatePermissionsParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates a template visibility permissions. A public template is visible to all accounts within the same domain. A private template is visible only to the owner of the template. A priviledged template is a private template with account permissions added. Only accounts specified under the template permissions are visible to them. -func (s *TemplateService) UpdateTemplatePermissions(p *UpdateTemplatePermissionsParams) (*UpdateTemplatePermissionsResponse, error) { - resp, err := s.cs.newRequest("updateTemplatePermissions", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateTemplatePermissionsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type UpdateTemplatePermissionsResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} - -type ListTemplatePermissionsParams struct { - p map[string]interface{} -} - -func (p *ListTemplatePermissionsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *ListTemplatePermissionsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new ListTemplatePermissionsParams instance, -// as then you are sure you have configured all required params -func (s *TemplateService) NewListTemplatePermissionsParams(id string) *ListTemplatePermissionsParams { - p := &ListTemplatePermissionsParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *TemplateService) GetTemplatePermissionByID(id string, opts ...OptionFunc) (*TemplatePermission, int, error) { - p := &ListTemplatePermissionsParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListTemplatePermissions(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.TemplatePermissions[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for TemplatePermission UUID: %s!", id) -} - -// List template visibility and all accounts that have permissions to view this template. -func (s *TemplateService) ListTemplatePermissions(p *ListTemplatePermissionsParams) (*ListTemplatePermissionsResponse, error) { - resp, err := s.cs.newRequest("listTemplatePermissions", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListTemplatePermissionsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListTemplatePermissionsResponse struct { - Count int `json:"count"` - TemplatePermissions []*TemplatePermission `json:"templatepermission"` -} - -type TemplatePermission struct { - Account []string `json:"account,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Ispublic bool `json:"ispublic,omitempty"` - Projectids []string `json:"projectids,omitempty"` -} - -type ExtractTemplateParams struct { - p map[string]interface{} -} - -func (p *ExtractTemplateParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["mode"]; found { - u.Set("mode", v.(string)) - } - if v, found := p.p["url"]; found { - u.Set("url", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ExtractTemplateParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ExtractTemplateParams) SetMode(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["mode"] = v - return -} - -func (p *ExtractTemplateParams) SetUrl(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["url"] = v - return -} - -func (p *ExtractTemplateParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ExtractTemplateParams instance, -// as then you are sure you have configured all required params -func (s *TemplateService) NewExtractTemplateParams(id string, mode string) *ExtractTemplateParams { - p := &ExtractTemplateParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - p.p["mode"] = mode - return p -} - -// Extracts a template -func (s *TemplateService) ExtractTemplate(p *ExtractTemplateParams) (*ExtractTemplateResponse, error) { - resp, err := s.cs.newRequest("extractTemplate", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ExtractTemplateResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type ExtractTemplateResponse struct { - JobID string `json:"jobid,omitempty"` - Accountid string `json:"accountid,omitempty"` - Created string `json:"created,omitempty"` - ExtractId string `json:"extractId,omitempty"` - ExtractMode string `json:"extractMode,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Resultstring string `json:"resultstring,omitempty"` - State string `json:"state,omitempty"` - Status string `json:"status,omitempty"` - Storagetype string `json:"storagetype,omitempty"` - Uploadpercentage int `json:"uploadpercentage,omitempty"` - Url string `json:"url,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type PrepareTemplateParams struct { - p map[string]interface{} -} - -func (p *PrepareTemplateParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["storageid"]; found { - u.Set("storageid", v.(string)) - } - if v, found := p.p["templateid"]; found { - u.Set("templateid", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *PrepareTemplateParams) SetStorageid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["storageid"] = v - return -} - -func (p *PrepareTemplateParams) SetTemplateid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["templateid"] = v - return -} - -func (p *PrepareTemplateParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new PrepareTemplateParams instance, -// as then you are sure you have configured all required params -func (s *TemplateService) NewPrepareTemplateParams(templateid string, zoneid string) *PrepareTemplateParams { - p := &PrepareTemplateParams{} - p.p = make(map[string]interface{}) - p.p["templateid"] = templateid - p.p["zoneid"] = zoneid - return p -} - -// load template into primary storage -func (s *TemplateService) PrepareTemplate(p *PrepareTemplateParams) (*PrepareTemplateResponse, error) { - resp, err := s.cs.newRequest("prepareTemplate", p.toURLValues()) - if err != nil { - return nil, err - } - - var r PrepareTemplateResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type PrepareTemplateResponse struct { - Account string `json:"account,omitempty"` - Accountid string `json:"accountid,omitempty"` - Bootable bool `json:"bootable,omitempty"` - Checksum string `json:"checksum,omitempty"` - Created string `json:"created,omitempty"` - CrossZones bool `json:"crossZones,omitempty"` - Details map[string]string `json:"details,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Format string `json:"format,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isextractable bool `json:"isextractable,omitempty"` - Isfeatured bool `json:"isfeatured,omitempty"` - Ispublic bool `json:"ispublic,omitempty"` - Isready bool `json:"isready,omitempty"` - Name string `json:"name,omitempty"` - Ostypeid string `json:"ostypeid,omitempty"` - Ostypename string `json:"ostypename,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Removed string `json:"removed,omitempty"` - Size int64 `json:"size,omitempty"` - Sourcetemplateid string `json:"sourcetemplateid,omitempty"` - Sshkeyenabled bool `json:"sshkeyenabled,omitempty"` - Status string `json:"status,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatetag string `json:"templatetag,omitempty"` - Templatetype string `json:"templatetype,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type UpgradeRouterTemplateParams struct { - p map[string]interface{} -} - -func (p *UpgradeRouterTemplateParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["clusterid"]; found { - u.Set("clusterid", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["podid"]; found { - u.Set("podid", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *UpgradeRouterTemplateParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *UpgradeRouterTemplateParams) SetClusterid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["clusterid"] = v - return -} - -func (p *UpgradeRouterTemplateParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *UpgradeRouterTemplateParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpgradeRouterTemplateParams) SetPodid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["podid"] = v - return -} - -func (p *UpgradeRouterTemplateParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new UpgradeRouterTemplateParams instance, -// as then you are sure you have configured all required params -func (s *TemplateService) NewUpgradeRouterTemplateParams() *UpgradeRouterTemplateParams { - p := &UpgradeRouterTemplateParams{} - p.p = make(map[string]interface{}) - return p -} - -// Upgrades router to use newer template -func (s *TemplateService) UpgradeRouterTemplate(p *UpgradeRouterTemplateParams) (*UpgradeRouterTemplateResponse, error) { - resp, err := s.cs.newRequest("upgradeRouterTemplate", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpgradeRouterTemplateResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type UpgradeRouterTemplateResponse struct { - Jobid string `json:"jobid,omitempty"` - Jobstatus int `json:"jobstatus,omitempty"` -} - -type GetUploadParamsForTemplateParams struct { - p map[string]interface{} -} - -func (p *GetUploadParamsForTemplateParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["bits"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("bits", vv) - } - if v, found := p.p["checksum"]; found { - u.Set("checksum", v.(string)) - } - if v, found := p.p["details"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("details[%d].key", i), k) - u.Set(fmt.Sprintf("details[%d].value", i), vv) - i++ - } - } - if v, found := p.p["displaytext"]; found { - u.Set("displaytext", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["format"]; found { - u.Set("format", v.(string)) - } - if v, found := p.p["hypervisor"]; found { - u.Set("hypervisor", v.(string)) - } - if v, found := p.p["isdynamicallyscalable"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isdynamicallyscalable", vv) - } - if v, found := p.p["isextractable"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isextractable", vv) - } - if v, found := p.p["isfeatured"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isfeatured", vv) - } - if v, found := p.p["ispublic"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("ispublic", vv) - } - if v, found := p.p["isrouting"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrouting", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["ostypeid"]; found { - u.Set("ostypeid", v.(string)) - } - if v, found := p.p["passwordenabled"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("passwordenabled", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["requireshvm"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("requireshvm", vv) - } - if v, found := p.p["sshkeyenabled"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("sshkeyenabled", vv) - } - if v, found := p.p["templatetag"]; found { - u.Set("templatetag", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *GetUploadParamsForTemplateParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *GetUploadParamsForTemplateParams) SetBits(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["bits"] = v - return -} - -func (p *GetUploadParamsForTemplateParams) SetChecksum(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["checksum"] = v - return -} - -func (p *GetUploadParamsForTemplateParams) SetDetails(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["details"] = v - return -} - -func (p *GetUploadParamsForTemplateParams) SetDisplaytext(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displaytext"] = v - return -} - -func (p *GetUploadParamsForTemplateParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *GetUploadParamsForTemplateParams) SetFormat(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["format"] = v - return -} - -func (p *GetUploadParamsForTemplateParams) SetHypervisor(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hypervisor"] = v - return -} - -func (p *GetUploadParamsForTemplateParams) SetIsdynamicallyscalable(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isdynamicallyscalable"] = v - return -} - -func (p *GetUploadParamsForTemplateParams) SetIsextractable(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isextractable"] = v - return -} - -func (p *GetUploadParamsForTemplateParams) SetIsfeatured(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isfeatured"] = v - return -} - -func (p *GetUploadParamsForTemplateParams) SetIspublic(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ispublic"] = v - return -} - -func (p *GetUploadParamsForTemplateParams) SetIsrouting(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrouting"] = v - return -} - -func (p *GetUploadParamsForTemplateParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *GetUploadParamsForTemplateParams) SetOstypeid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ostypeid"] = v - return -} - -func (p *GetUploadParamsForTemplateParams) SetPasswordenabled(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["passwordenabled"] = v - return -} - -func (p *GetUploadParamsForTemplateParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *GetUploadParamsForTemplateParams) SetRequireshvm(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["requireshvm"] = v - return -} - -func (p *GetUploadParamsForTemplateParams) SetSshkeyenabled(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["sshkeyenabled"] = v - return -} - -func (p *GetUploadParamsForTemplateParams) SetTemplatetag(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["templatetag"] = v - return -} - -func (p *GetUploadParamsForTemplateParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new GetUploadParamsForTemplateParams instance, -// as then you are sure you have configured all required params -func (s *TemplateService) NewGetUploadParamsForTemplateParams(displaytext string, format string, hypervisor string, name string, ostypeid string, zoneid string) *GetUploadParamsForTemplateParams { - p := &GetUploadParamsForTemplateParams{} - p.p = make(map[string]interface{}) - p.p["displaytext"] = displaytext - p.p["format"] = format - p.p["hypervisor"] = hypervisor - p.p["name"] = name - p.p["ostypeid"] = ostypeid - p.p["zoneid"] = zoneid - return p -} - -// upload an existing template into the CloudStack cloud. -func (s *TemplateService) GetUploadParamsForTemplate(p *GetUploadParamsForTemplateParams) (*GetUploadParamsForTemplateResponse, error) { - resp, err := s.cs.newRequest("getUploadParamsForTemplate", p.toURLValues()) - if err != nil { - return nil, err - } - - var r GetUploadParamsForTemplateResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type GetUploadParamsForTemplateResponse struct { - Expires string `json:"expires,omitempty"` - Id string `json:"id,omitempty"` - Metadata string `json:"metadata,omitempty"` - PostURL string `json:"postURL,omitempty"` - Signature string `json:"signature,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/UCSService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/UCSService.go deleted file mode 100644 index 3d5fbd33a81..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/UCSService.go +++ /dev/null @@ -1,594 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type AddUcsManagerParams struct { - p map[string]interface{} -} - -func (p *AddUcsManagerParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["password"]; found { - u.Set("password", v.(string)) - } - if v, found := p.p["url"]; found { - u.Set("url", v.(string)) - } - if v, found := p.p["username"]; found { - u.Set("username", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *AddUcsManagerParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *AddUcsManagerParams) SetPassword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["password"] = v - return -} - -func (p *AddUcsManagerParams) SetUrl(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["url"] = v - return -} - -func (p *AddUcsManagerParams) SetUsername(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["username"] = v - return -} - -func (p *AddUcsManagerParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new AddUcsManagerParams instance, -// as then you are sure you have configured all required params -func (s *UCSService) NewAddUcsManagerParams(password string, url string, username string, zoneid string) *AddUcsManagerParams { - p := &AddUcsManagerParams{} - p.p = make(map[string]interface{}) - p.p["password"] = password - p.p["url"] = url - p.p["username"] = username - p.p["zoneid"] = zoneid - return p -} - -// Adds a Ucs manager -func (s *UCSService) AddUcsManager(p *AddUcsManagerParams) (*AddUcsManagerResponse, error) { - resp, err := s.cs.newRequest("addUcsManager", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AddUcsManagerResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type AddUcsManagerResponse struct { - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Url string `json:"url,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type ListUcsManagersParams struct { - p map[string]interface{} -} - -func (p *ListUcsManagersParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ListUcsManagersParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListUcsManagersParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListUcsManagersParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListUcsManagersParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListUcsManagersParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ListUcsManagersParams instance, -// as then you are sure you have configured all required params -func (s *UCSService) NewListUcsManagersParams() *ListUcsManagersParams { - p := &ListUcsManagersParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *UCSService) GetUcsManagerID(keyword string, opts ...OptionFunc) (string, int, error) { - p := &ListUcsManagersParams{} - p.p = make(map[string]interface{}) - - p.p["keyword"] = keyword - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListUcsManagers(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", keyword, l) - } - - if l.Count == 1 { - return l.UcsManagers[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.UcsManagers { - if v.Name == keyword { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *UCSService) GetUcsManagerByName(name string, opts ...OptionFunc) (*UcsManager, int, error) { - id, count, err := s.GetUcsManagerID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetUcsManagerByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *UCSService) GetUcsManagerByID(id string, opts ...OptionFunc) (*UcsManager, int, error) { - p := &ListUcsManagersParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListUcsManagers(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.UcsManagers[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for UcsManager UUID: %s!", id) -} - -// List ucs manager -func (s *UCSService) ListUcsManagers(p *ListUcsManagersParams) (*ListUcsManagersResponse, error) { - resp, err := s.cs.newRequest("listUcsManagers", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListUcsManagersResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListUcsManagersResponse struct { - Count int `json:"count"` - UcsManagers []*UcsManager `json:"ucsmanager"` -} - -type UcsManager struct { - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Url string `json:"url,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type ListUcsProfilesParams struct { - p map[string]interface{} -} - -func (p *ListUcsProfilesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["ucsmanagerid"]; found { - u.Set("ucsmanagerid", v.(string)) - } - return u -} - -func (p *ListUcsProfilesParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListUcsProfilesParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListUcsProfilesParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListUcsProfilesParams) SetUcsmanagerid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ucsmanagerid"] = v - return -} - -// You should always use this function to get a new ListUcsProfilesParams instance, -// as then you are sure you have configured all required params -func (s *UCSService) NewListUcsProfilesParams(ucsmanagerid string) *ListUcsProfilesParams { - p := &ListUcsProfilesParams{} - p.p = make(map[string]interface{}) - p.p["ucsmanagerid"] = ucsmanagerid - return p -} - -// List profile in ucs manager -func (s *UCSService) ListUcsProfiles(p *ListUcsProfilesParams) (*ListUcsProfilesResponse, error) { - resp, err := s.cs.newRequest("listUcsProfiles", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListUcsProfilesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListUcsProfilesResponse struct { - Count int `json:"count"` - UcsProfiles []*UcsProfile `json:"ucsprofile"` -} - -type UcsProfile struct { - Ucsdn string `json:"ucsdn,omitempty"` -} - -type ListUcsBladesParams struct { - p map[string]interface{} -} - -func (p *ListUcsBladesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["ucsmanagerid"]; found { - u.Set("ucsmanagerid", v.(string)) - } - return u -} - -func (p *ListUcsBladesParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListUcsBladesParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListUcsBladesParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListUcsBladesParams) SetUcsmanagerid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ucsmanagerid"] = v - return -} - -// You should always use this function to get a new ListUcsBladesParams instance, -// as then you are sure you have configured all required params -func (s *UCSService) NewListUcsBladesParams(ucsmanagerid string) *ListUcsBladesParams { - p := &ListUcsBladesParams{} - p.p = make(map[string]interface{}) - p.p["ucsmanagerid"] = ucsmanagerid - return p -} - -// List ucs blades -func (s *UCSService) ListUcsBlades(p *ListUcsBladesParams) (*ListUcsBladesResponse, error) { - resp, err := s.cs.newRequest("listUcsBlades", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListUcsBladesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListUcsBladesResponse struct { - Count int `json:"count"` - UcsBlades []*UcsBlade `json:"ucsblade"` -} - -type UcsBlade struct { - Bladedn string `json:"bladedn,omitempty"` - Hostid string `json:"hostid,omitempty"` - Id string `json:"id,omitempty"` - Profiledn string `json:"profiledn,omitempty"` - Ucsmanagerid string `json:"ucsmanagerid,omitempty"` -} - -type AssociateUcsProfileToBladeParams struct { - p map[string]interface{} -} - -func (p *AssociateUcsProfileToBladeParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["bladeid"]; found { - u.Set("bladeid", v.(string)) - } - if v, found := p.p["profiledn"]; found { - u.Set("profiledn", v.(string)) - } - if v, found := p.p["ucsmanagerid"]; found { - u.Set("ucsmanagerid", v.(string)) - } - return u -} - -func (p *AssociateUcsProfileToBladeParams) SetBladeid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["bladeid"] = v - return -} - -func (p *AssociateUcsProfileToBladeParams) SetProfiledn(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["profiledn"] = v - return -} - -func (p *AssociateUcsProfileToBladeParams) SetUcsmanagerid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ucsmanagerid"] = v - return -} - -// You should always use this function to get a new AssociateUcsProfileToBladeParams instance, -// as then you are sure you have configured all required params -func (s *UCSService) NewAssociateUcsProfileToBladeParams(bladeid string, profiledn string, ucsmanagerid string) *AssociateUcsProfileToBladeParams { - p := &AssociateUcsProfileToBladeParams{} - p.p = make(map[string]interface{}) - p.p["bladeid"] = bladeid - p.p["profiledn"] = profiledn - p.p["ucsmanagerid"] = ucsmanagerid - return p -} - -// associate a profile to a blade -func (s *UCSService) AssociateUcsProfileToBlade(p *AssociateUcsProfileToBladeParams) (*AssociateUcsProfileToBladeResponse, error) { - resp, err := s.cs.newRequest("associateUcsProfileToBlade", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AssociateUcsProfileToBladeResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type AssociateUcsProfileToBladeResponse struct { - JobID string `json:"jobid,omitempty"` - Bladedn string `json:"bladedn,omitempty"` - Hostid string `json:"hostid,omitempty"` - Id string `json:"id,omitempty"` - Profiledn string `json:"profiledn,omitempty"` - Ucsmanagerid string `json:"ucsmanagerid,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/UsageService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/UsageService.go deleted file mode 100644 index a38b69f1b4d..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/UsageService.go +++ /dev/null @@ -1,1213 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" -) - -type AddTrafficTypeParams struct { - p map[string]interface{} -} - -func (p *AddTrafficTypeParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["hypervnetworklabel"]; found { - u.Set("hypervnetworklabel", v.(string)) - } - if v, found := p.p["isolationmethod"]; found { - u.Set("isolationmethod", v.(string)) - } - if v, found := p.p["kvmnetworklabel"]; found { - u.Set("kvmnetworklabel", v.(string)) - } - if v, found := p.p["ovm3networklabel"]; found { - u.Set("ovm3networklabel", v.(string)) - } - if v, found := p.p["physicalnetworkid"]; found { - u.Set("physicalnetworkid", v.(string)) - } - if v, found := p.p["traffictype"]; found { - u.Set("traffictype", v.(string)) - } - if v, found := p.p["vlan"]; found { - u.Set("vlan", v.(string)) - } - if v, found := p.p["vmwarenetworklabel"]; found { - u.Set("vmwarenetworklabel", v.(string)) - } - if v, found := p.p["xennetworklabel"]; found { - u.Set("xennetworklabel", v.(string)) - } - return u -} - -func (p *AddTrafficTypeParams) SetHypervnetworklabel(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hypervnetworklabel"] = v - return -} - -func (p *AddTrafficTypeParams) SetIsolationmethod(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isolationmethod"] = v - return -} - -func (p *AddTrafficTypeParams) SetKvmnetworklabel(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["kvmnetworklabel"] = v - return -} - -func (p *AddTrafficTypeParams) SetOvm3networklabel(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ovm3networklabel"] = v - return -} - -func (p *AddTrafficTypeParams) SetPhysicalnetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["physicalnetworkid"] = v - return -} - -func (p *AddTrafficTypeParams) SetTraffictype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["traffictype"] = v - return -} - -func (p *AddTrafficTypeParams) SetVlan(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vlan"] = v - return -} - -func (p *AddTrafficTypeParams) SetVmwarenetworklabel(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vmwarenetworklabel"] = v - return -} - -func (p *AddTrafficTypeParams) SetXennetworklabel(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["xennetworklabel"] = v - return -} - -// You should always use this function to get a new AddTrafficTypeParams instance, -// as then you are sure you have configured all required params -func (s *UsageService) NewAddTrafficTypeParams(physicalnetworkid string, traffictype string) *AddTrafficTypeParams { - p := &AddTrafficTypeParams{} - p.p = make(map[string]interface{}) - p.p["physicalnetworkid"] = physicalnetworkid - p.p["traffictype"] = traffictype - return p -} - -// Adds traffic type to a physical network -func (s *UsageService) AddTrafficType(p *AddTrafficTypeParams) (*AddTrafficTypeResponse, error) { - resp, err := s.cs.newRequest("addTrafficType", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AddTrafficTypeResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type AddTrafficTypeResponse struct { - JobID string `json:"jobid,omitempty"` - Hypervnetworklabel string `json:"hypervnetworklabel,omitempty"` - Id string `json:"id,omitempty"` - Kvmnetworklabel string `json:"kvmnetworklabel,omitempty"` - Ovm3networklabel string `json:"ovm3networklabel,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Vmwarenetworklabel string `json:"vmwarenetworklabel,omitempty"` - Xennetworklabel string `json:"xennetworklabel,omitempty"` -} - -type DeleteTrafficTypeParams struct { - p map[string]interface{} -} - -func (p *DeleteTrafficTypeParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteTrafficTypeParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteTrafficTypeParams instance, -// as then you are sure you have configured all required params -func (s *UsageService) NewDeleteTrafficTypeParams(id string) *DeleteTrafficTypeParams { - p := &DeleteTrafficTypeParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes traffic type of a physical network -func (s *UsageService) DeleteTrafficType(p *DeleteTrafficTypeParams) (*DeleteTrafficTypeResponse, error) { - resp, err := s.cs.newRequest("deleteTrafficType", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteTrafficTypeResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteTrafficTypeResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListTrafficTypesParams struct { - p map[string]interface{} -} - -func (p *ListTrafficTypesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["physicalnetworkid"]; found { - u.Set("physicalnetworkid", v.(string)) - } - return u -} - -func (p *ListTrafficTypesParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListTrafficTypesParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListTrafficTypesParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListTrafficTypesParams) SetPhysicalnetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["physicalnetworkid"] = v - return -} - -// You should always use this function to get a new ListTrafficTypesParams instance, -// as then you are sure you have configured all required params -func (s *UsageService) NewListTrafficTypesParams(physicalnetworkid string) *ListTrafficTypesParams { - p := &ListTrafficTypesParams{} - p.p = make(map[string]interface{}) - p.p["physicalnetworkid"] = physicalnetworkid - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *UsageService) GetTrafficTypeID(keyword string, physicalnetworkid string, opts ...OptionFunc) (string, int, error) { - p := &ListTrafficTypesParams{} - p.p = make(map[string]interface{}) - - p.p["keyword"] = keyword - p.p["physicalnetworkid"] = physicalnetworkid - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListTrafficTypes(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", keyword, l) - } - - if l.Count == 1 { - return l.TrafficTypes[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.TrafficTypes { - if v.Name == keyword { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l) -} - -// Lists traffic types of a given physical network. -func (s *UsageService) ListTrafficTypes(p *ListTrafficTypesParams) (*ListTrafficTypesResponse, error) { - resp, err := s.cs.newRequest("listTrafficTypes", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListTrafficTypesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListTrafficTypesResponse struct { - Count int `json:"count"` - TrafficTypes []*TrafficType `json:"traffictype"` -} - -type TrafficType struct { - Canenableindividualservice bool `json:"canenableindividualservice,omitempty"` - Destinationphysicalnetworkid string `json:"destinationphysicalnetworkid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Servicelist []string `json:"servicelist,omitempty"` - State string `json:"state,omitempty"` -} - -type UpdateTrafficTypeParams struct { - p map[string]interface{} -} - -func (p *UpdateTrafficTypeParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["hypervnetworklabel"]; found { - u.Set("hypervnetworklabel", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["kvmnetworklabel"]; found { - u.Set("kvmnetworklabel", v.(string)) - } - if v, found := p.p["ovm3networklabel"]; found { - u.Set("ovm3networklabel", v.(string)) - } - if v, found := p.p["vmwarenetworklabel"]; found { - u.Set("vmwarenetworklabel", v.(string)) - } - if v, found := p.p["xennetworklabel"]; found { - u.Set("xennetworklabel", v.(string)) - } - return u -} - -func (p *UpdateTrafficTypeParams) SetHypervnetworklabel(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hypervnetworklabel"] = v - return -} - -func (p *UpdateTrafficTypeParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateTrafficTypeParams) SetKvmnetworklabel(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["kvmnetworklabel"] = v - return -} - -func (p *UpdateTrafficTypeParams) SetOvm3networklabel(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ovm3networklabel"] = v - return -} - -func (p *UpdateTrafficTypeParams) SetVmwarenetworklabel(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vmwarenetworklabel"] = v - return -} - -func (p *UpdateTrafficTypeParams) SetXennetworklabel(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["xennetworklabel"] = v - return -} - -// You should always use this function to get a new UpdateTrafficTypeParams instance, -// as then you are sure you have configured all required params -func (s *UsageService) NewUpdateTrafficTypeParams(id string) *UpdateTrafficTypeParams { - p := &UpdateTrafficTypeParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates traffic type of a physical network -func (s *UsageService) UpdateTrafficType(p *UpdateTrafficTypeParams) (*UpdateTrafficTypeResponse, error) { - resp, err := s.cs.newRequest("updateTrafficType", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateTrafficTypeResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateTrafficTypeResponse struct { - JobID string `json:"jobid,omitempty"` - Hypervnetworklabel string `json:"hypervnetworklabel,omitempty"` - Id string `json:"id,omitempty"` - Kvmnetworklabel string `json:"kvmnetworklabel,omitempty"` - Ovm3networklabel string `json:"ovm3networklabel,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Vmwarenetworklabel string `json:"vmwarenetworklabel,omitempty"` - Xennetworklabel string `json:"xennetworklabel,omitempty"` -} - -type ListTrafficTypeImplementorsParams struct { - p map[string]interface{} -} - -func (p *ListTrafficTypeImplementorsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["traffictype"]; found { - u.Set("traffictype", v.(string)) - } - return u -} - -func (p *ListTrafficTypeImplementorsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListTrafficTypeImplementorsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListTrafficTypeImplementorsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListTrafficTypeImplementorsParams) SetTraffictype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["traffictype"] = v - return -} - -// You should always use this function to get a new ListTrafficTypeImplementorsParams instance, -// as then you are sure you have configured all required params -func (s *UsageService) NewListTrafficTypeImplementorsParams() *ListTrafficTypeImplementorsParams { - p := &ListTrafficTypeImplementorsParams{} - p.p = make(map[string]interface{}) - return p -} - -// Lists implementors of implementor of a network traffic type or implementors of all network traffic types -func (s *UsageService) ListTrafficTypeImplementors(p *ListTrafficTypeImplementorsParams) (*ListTrafficTypeImplementorsResponse, error) { - resp, err := s.cs.newRequest("listTrafficTypeImplementors", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListTrafficTypeImplementorsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListTrafficTypeImplementorsResponse struct { - Count int `json:"count"` - TrafficTypeImplementors []*TrafficTypeImplementor `json:"traffictypeimplementor"` -} - -type TrafficTypeImplementor struct { - Traffictype string `json:"traffictype,omitempty"` - Traffictypeimplementor string `json:"traffictypeimplementor,omitempty"` -} - -type GenerateUsageRecordsParams struct { - p map[string]interface{} -} - -func (p *GenerateUsageRecordsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["enddate"]; found { - u.Set("enddate", v.(string)) - } - if v, found := p.p["startdate"]; found { - u.Set("startdate", v.(string)) - } - return u -} - -func (p *GenerateUsageRecordsParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *GenerateUsageRecordsParams) SetEnddate(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["enddate"] = v - return -} - -func (p *GenerateUsageRecordsParams) SetStartdate(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["startdate"] = v - return -} - -// You should always use this function to get a new GenerateUsageRecordsParams instance, -// as then you are sure you have configured all required params -func (s *UsageService) NewGenerateUsageRecordsParams(enddate string, startdate string) *GenerateUsageRecordsParams { - p := &GenerateUsageRecordsParams{} - p.p = make(map[string]interface{}) - p.p["enddate"] = enddate - p.p["startdate"] = startdate - return p -} - -// Generates usage records. This will generate records only if there any records to be generated, i.e if the scheduled usage job was not run or failed -func (s *UsageService) GenerateUsageRecords(p *GenerateUsageRecordsParams) (*GenerateUsageRecordsResponse, error) { - resp, err := s.cs.newRequest("generateUsageRecords", p.toURLValues()) - if err != nil { - return nil, err - } - - var r GenerateUsageRecordsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type GenerateUsageRecordsResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} - -type ListUsageRecordsParams struct { - p map[string]interface{} -} - -func (p *ListUsageRecordsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["accountid"]; found { - u.Set("accountid", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["enddate"]; found { - u.Set("enddate", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["startdate"]; found { - u.Set("startdate", v.(string)) - } - if v, found := p.p["type"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("type", vv) - } - if v, found := p.p["usageid"]; found { - u.Set("usageid", v.(string)) - } - return u -} - -func (p *ListUsageRecordsParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListUsageRecordsParams) SetAccountid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["accountid"] = v - return -} - -func (p *ListUsageRecordsParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListUsageRecordsParams) SetEnddate(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["enddate"] = v - return -} - -func (p *ListUsageRecordsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListUsageRecordsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListUsageRecordsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListUsageRecordsParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListUsageRecordsParams) SetStartdate(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["startdate"] = v - return -} - -func (p *ListUsageRecordsParams) SetType(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["usageType"] = v - return -} - -func (p *ListUsageRecordsParams) SetUsageid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["usageid"] = v - return -} - -// You should always use this function to get a new ListUsageRecordsParams instance, -// as then you are sure you have configured all required params -func (s *UsageService) NewListUsageRecordsParams(enddate string, startdate string) *ListUsageRecordsParams { - p := &ListUsageRecordsParams{} - p.p = make(map[string]interface{}) - p.p["enddate"] = enddate - p.p["startdate"] = startdate - return p -} - -// Lists usage records for accounts -func (s *UsageService) ListUsageRecords(p *ListUsageRecordsParams) (*ListUsageRecordsResponse, error) { - resp, err := s.cs.newRequest("listUsageRecords", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListUsageRecordsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListUsageRecordsResponse struct { - Count int `json:"count"` - UsageRecords []*UsageRecord `json:"usagerecord"` -} - -type UsageRecord struct { - Account string `json:"account,omitempty"` - Accountid string `json:"accountid,omitempty"` - Cpunumber int64 `json:"cpunumber,omitempty"` - Cpuspeed int64 `json:"cpuspeed,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Enddate string `json:"enddate,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Issourcenat bool `json:"issourcenat,omitempty"` - Issystem bool `json:"issystem,omitempty"` - Memory int64 `json:"memory,omitempty"` - Name string `json:"name,omitempty"` - Networkid string `json:"networkid,omitempty"` - Offeringid string `json:"offeringid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Rawusage string `json:"rawusage,omitempty"` - Size int64 `json:"size,omitempty"` - Startdate string `json:"startdate,omitempty"` - Templateid string `json:"templateid,omitempty"` - Type string `json:"type,omitempty"` - Usage string `json:"usage,omitempty"` - Usageid string `json:"usageid,omitempty"` - Usagetype int `json:"usagetype,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - Virtualsize int64 `json:"virtualsize,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type ListUsageTypesParams struct { - p map[string]interface{} -} - -func (p *ListUsageTypesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - return u -} - -// You should always use this function to get a new ListUsageTypesParams instance, -// as then you are sure you have configured all required params -func (s *UsageService) NewListUsageTypesParams() *ListUsageTypesParams { - p := &ListUsageTypesParams{} - p.p = make(map[string]interface{}) - return p -} - -// List Usage Types -func (s *UsageService) ListUsageTypes(p *ListUsageTypesParams) (*ListUsageTypesResponse, error) { - resp, err := s.cs.newRequest("listUsageTypes", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListUsageTypesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListUsageTypesResponse struct { - Count int `json:"count"` - UsageTypes []*UsageType `json:"usagetype"` -} - -type UsageType struct { - Description string `json:"description,omitempty"` - Usagetypeid int `json:"usagetypeid,omitempty"` -} - -type RemoveRawUsageRecordsParams struct { - p map[string]interface{} -} - -func (p *RemoveRawUsageRecordsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["interval"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("interval", vv) - } - return u -} - -func (p *RemoveRawUsageRecordsParams) SetInterval(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["interval"] = v - return -} - -// You should always use this function to get a new RemoveRawUsageRecordsParams instance, -// as then you are sure you have configured all required params -func (s *UsageService) NewRemoveRawUsageRecordsParams(interval int) *RemoveRawUsageRecordsParams { - p := &RemoveRawUsageRecordsParams{} - p.p = make(map[string]interface{}) - p.p["interval"] = interval - return p -} - -// Safely removes raw records from cloud_usage table -func (s *UsageService) RemoveRawUsageRecords(p *RemoveRawUsageRecordsParams) (*RemoveRawUsageRecordsResponse, error) { - resp, err := s.cs.newRequest("removeRawUsageRecords", p.toURLValues()) - if err != nil { - return nil, err - } - - var r RemoveRawUsageRecordsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type RemoveRawUsageRecordsResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} - -type AddTrafficMonitorParams struct { - p map[string]interface{} -} - -func (p *AddTrafficMonitorParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["excludezones"]; found { - u.Set("excludezones", v.(string)) - } - if v, found := p.p["includezones"]; found { - u.Set("includezones", v.(string)) - } - if v, found := p.p["url"]; found { - u.Set("url", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *AddTrafficMonitorParams) SetExcludezones(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["excludezones"] = v - return -} - -func (p *AddTrafficMonitorParams) SetIncludezones(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["includezones"] = v - return -} - -func (p *AddTrafficMonitorParams) SetUrl(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["url"] = v - return -} - -func (p *AddTrafficMonitorParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new AddTrafficMonitorParams instance, -// as then you are sure you have configured all required params -func (s *UsageService) NewAddTrafficMonitorParams(url string, zoneid string) *AddTrafficMonitorParams { - p := &AddTrafficMonitorParams{} - p.p = make(map[string]interface{}) - p.p["url"] = url - p.p["zoneid"] = zoneid - return p -} - -// Adds Traffic Monitor Host for Direct Network Usage -func (s *UsageService) AddTrafficMonitor(p *AddTrafficMonitorParams) (*AddTrafficMonitorResponse, error) { - resp, err := s.cs.newRequest("addTrafficMonitor", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AddTrafficMonitorResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type AddTrafficMonitorResponse struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Numretries string `json:"numretries,omitempty"` - Timeout string `json:"timeout,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type DeleteTrafficMonitorParams struct { - p map[string]interface{} -} - -func (p *DeleteTrafficMonitorParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteTrafficMonitorParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteTrafficMonitorParams instance, -// as then you are sure you have configured all required params -func (s *UsageService) NewDeleteTrafficMonitorParams(id string) *DeleteTrafficMonitorParams { - p := &DeleteTrafficMonitorParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes an traffic monitor host. -func (s *UsageService) DeleteTrafficMonitor(p *DeleteTrafficMonitorParams) (*DeleteTrafficMonitorResponse, error) { - resp, err := s.cs.newRequest("deleteTrafficMonitor", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteTrafficMonitorResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type DeleteTrafficMonitorResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} - -type ListTrafficMonitorsParams struct { - p map[string]interface{} -} - -func (p *ListTrafficMonitorsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ListTrafficMonitorsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListTrafficMonitorsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListTrafficMonitorsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListTrafficMonitorsParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ListTrafficMonitorsParams instance, -// as then you are sure you have configured all required params -func (s *UsageService) NewListTrafficMonitorsParams(zoneid string) *ListTrafficMonitorsParams { - p := &ListTrafficMonitorsParams{} - p.p = make(map[string]interface{}) - p.p["zoneid"] = zoneid - return p -} - -// List traffic monitor Hosts. -func (s *UsageService) ListTrafficMonitors(p *ListTrafficMonitorsParams) (*ListTrafficMonitorsResponse, error) { - resp, err := s.cs.newRequest("listTrafficMonitors", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListTrafficMonitorsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListTrafficMonitorsResponse struct { - Count int `json:"count"` - TrafficMonitors []*TrafficMonitor `json:"trafficmonitor"` -} - -type TrafficMonitor struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Numretries string `json:"numretries,omitempty"` - Timeout string `json:"timeout,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/UserService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/UserService.go deleted file mode 100644 index cf091225d4b..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/UserService.go +++ /dev/null @@ -1,1239 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type CreateUserParams struct { - p map[string]interface{} -} - -func (p *CreateUserParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["email"]; found { - u.Set("email", v.(string)) - } - if v, found := p.p["firstname"]; found { - u.Set("firstname", v.(string)) - } - if v, found := p.p["lastname"]; found { - u.Set("lastname", v.(string)) - } - if v, found := p.p["password"]; found { - u.Set("password", v.(string)) - } - if v, found := p.p["timezone"]; found { - u.Set("timezone", v.(string)) - } - if v, found := p.p["userid"]; found { - u.Set("userid", v.(string)) - } - if v, found := p.p["username"]; found { - u.Set("username", v.(string)) - } - return u -} - -func (p *CreateUserParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *CreateUserParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *CreateUserParams) SetEmail(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["email"] = v - return -} - -func (p *CreateUserParams) SetFirstname(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["firstname"] = v - return -} - -func (p *CreateUserParams) SetLastname(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["lastname"] = v - return -} - -func (p *CreateUserParams) SetPassword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["password"] = v - return -} - -func (p *CreateUserParams) SetTimezone(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["timezone"] = v - return -} - -func (p *CreateUserParams) SetUserid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["userid"] = v - return -} - -func (p *CreateUserParams) SetUsername(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["username"] = v - return -} - -// You should always use this function to get a new CreateUserParams instance, -// as then you are sure you have configured all required params -func (s *UserService) NewCreateUserParams(account string, email string, firstname string, lastname string, password string, username string) *CreateUserParams { - p := &CreateUserParams{} - p.p = make(map[string]interface{}) - p.p["account"] = account - p.p["email"] = email - p.p["firstname"] = firstname - p.p["lastname"] = lastname - p.p["password"] = password - p.p["username"] = username - return p -} - -// Creates a user for an account that already exists -func (s *UserService) CreateUser(p *CreateUserParams) (*CreateUserResponse, error) { - resp, err := s.cs.newRequest("createUser", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateUserResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type CreateUserResponse struct { - Account string `json:"account,omitempty"` - Accountid string `json:"accountid,omitempty"` - Accounttype int `json:"accounttype,omitempty"` - Apikey string `json:"apikey,omitempty"` - Created string `json:"created,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Email string `json:"email,omitempty"` - Firstname string `json:"firstname,omitempty"` - Id string `json:"id,omitempty"` - Iscallerchilddomain bool `json:"iscallerchilddomain,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Lastname string `json:"lastname,omitempty"` - Secretkey string `json:"secretkey,omitempty"` - State string `json:"state,omitempty"` - Timezone string `json:"timezone,omitempty"` - Username string `json:"username,omitempty"` -} - -type DeleteUserParams struct { - p map[string]interface{} -} - -func (p *DeleteUserParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteUserParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteUserParams instance, -// as then you are sure you have configured all required params -func (s *UserService) NewDeleteUserParams(id string) *DeleteUserParams { - p := &DeleteUserParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a user for an account -func (s *UserService) DeleteUser(p *DeleteUserParams) (*DeleteUserResponse, error) { - resp, err := s.cs.newRequest("deleteUser", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteUserResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type DeleteUserResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} - -type UpdateUserParams struct { - p map[string]interface{} -} - -func (p *UpdateUserParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["email"]; found { - u.Set("email", v.(string)) - } - if v, found := p.p["firstname"]; found { - u.Set("firstname", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["lastname"]; found { - u.Set("lastname", v.(string)) - } - if v, found := p.p["password"]; found { - u.Set("password", v.(string)) - } - if v, found := p.p["timezone"]; found { - u.Set("timezone", v.(string)) - } - if v, found := p.p["userapikey"]; found { - u.Set("userapikey", v.(string)) - } - if v, found := p.p["username"]; found { - u.Set("username", v.(string)) - } - if v, found := p.p["usersecretkey"]; found { - u.Set("usersecretkey", v.(string)) - } - return u -} - -func (p *UpdateUserParams) SetEmail(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["email"] = v - return -} - -func (p *UpdateUserParams) SetFirstname(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["firstname"] = v - return -} - -func (p *UpdateUserParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateUserParams) SetLastname(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["lastname"] = v - return -} - -func (p *UpdateUserParams) SetPassword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["password"] = v - return -} - -func (p *UpdateUserParams) SetTimezone(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["timezone"] = v - return -} - -func (p *UpdateUserParams) SetUserapikey(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["userapikey"] = v - return -} - -func (p *UpdateUserParams) SetUsername(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["username"] = v - return -} - -func (p *UpdateUserParams) SetUsersecretkey(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["usersecretkey"] = v - return -} - -// You should always use this function to get a new UpdateUserParams instance, -// as then you are sure you have configured all required params -func (s *UserService) NewUpdateUserParams(id string) *UpdateUserParams { - p := &UpdateUserParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates a user account -func (s *UserService) UpdateUser(p *UpdateUserParams) (*UpdateUserResponse, error) { - resp, err := s.cs.newRequest("updateUser", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateUserResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type UpdateUserResponse struct { - Account string `json:"account,omitempty"` - Accountid string `json:"accountid,omitempty"` - Accounttype int `json:"accounttype,omitempty"` - Apikey string `json:"apikey,omitempty"` - Created string `json:"created,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Email string `json:"email,omitempty"` - Firstname string `json:"firstname,omitempty"` - Id string `json:"id,omitempty"` - Iscallerchilddomain bool `json:"iscallerchilddomain,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Lastname string `json:"lastname,omitempty"` - Secretkey string `json:"secretkey,omitempty"` - State string `json:"state,omitempty"` - Timezone string `json:"timezone,omitempty"` - Username string `json:"username,omitempty"` -} - -type ListUsersParams struct { - p map[string]interface{} -} - -func (p *ListUsersParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["accounttype"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("accounttype", vv) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["state"]; found { - u.Set("state", v.(string)) - } - if v, found := p.p["username"]; found { - u.Set("username", v.(string)) - } - return u -} - -func (p *ListUsersParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListUsersParams) SetAccounttype(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["accounttype"] = v - return -} - -func (p *ListUsersParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListUsersParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListUsersParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListUsersParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListUsersParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListUsersParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListUsersParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListUsersParams) SetState(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["state"] = v - return -} - -func (p *ListUsersParams) SetUsername(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["username"] = v - return -} - -// You should always use this function to get a new ListUsersParams instance, -// as then you are sure you have configured all required params -func (s *UserService) NewListUsersParams() *ListUsersParams { - p := &ListUsersParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *UserService) GetUserByID(id string, opts ...OptionFunc) (*User, int, error) { - p := &ListUsersParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListUsers(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.Users[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for User UUID: %s!", id) -} - -// Lists user accounts -func (s *UserService) ListUsers(p *ListUsersParams) (*ListUsersResponse, error) { - resp, err := s.cs.newRequest("listUsers", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListUsersResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListUsersResponse struct { - Count int `json:"count"` - Users []*User `json:"user"` -} - -type User struct { - Account string `json:"account,omitempty"` - Accountid string `json:"accountid,omitempty"` - Accounttype int `json:"accounttype,omitempty"` - Apikey string `json:"apikey,omitempty"` - Created string `json:"created,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Email string `json:"email,omitempty"` - Firstname string `json:"firstname,omitempty"` - Id string `json:"id,omitempty"` - Iscallerchilddomain bool `json:"iscallerchilddomain,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Lastname string `json:"lastname,omitempty"` - Secretkey string `json:"secretkey,omitempty"` - State string `json:"state,omitempty"` - Timezone string `json:"timezone,omitempty"` - Username string `json:"username,omitempty"` -} - -type LockUserParams struct { - p map[string]interface{} -} - -func (p *LockUserParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *LockUserParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new LockUserParams instance, -// as then you are sure you have configured all required params -func (s *UserService) NewLockUserParams(id string) *LockUserParams { - p := &LockUserParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Locks a user account -func (s *UserService) LockUser(p *LockUserParams) (*LockUserResponse, error) { - resp, err := s.cs.newRequest("lockUser", p.toURLValues()) - if err != nil { - return nil, err - } - - var r LockUserResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type LockUserResponse struct { - Account string `json:"account,omitempty"` - Accountid string `json:"accountid,omitempty"` - Accounttype int `json:"accounttype,omitempty"` - Apikey string `json:"apikey,omitempty"` - Created string `json:"created,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Email string `json:"email,omitempty"` - Firstname string `json:"firstname,omitempty"` - Id string `json:"id,omitempty"` - Iscallerchilddomain bool `json:"iscallerchilddomain,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Lastname string `json:"lastname,omitempty"` - Secretkey string `json:"secretkey,omitempty"` - State string `json:"state,omitempty"` - Timezone string `json:"timezone,omitempty"` - Username string `json:"username,omitempty"` -} - -type DisableUserParams struct { - p map[string]interface{} -} - -func (p *DisableUserParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DisableUserParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DisableUserParams instance, -// as then you are sure you have configured all required params -func (s *UserService) NewDisableUserParams(id string) *DisableUserParams { - p := &DisableUserParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Disables a user account -func (s *UserService) DisableUser(p *DisableUserParams) (*DisableUserResponse, error) { - resp, err := s.cs.newRequest("disableUser", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DisableUserResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DisableUserResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Accountid string `json:"accountid,omitempty"` - Accounttype int `json:"accounttype,omitempty"` - Apikey string `json:"apikey,omitempty"` - Created string `json:"created,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Email string `json:"email,omitempty"` - Firstname string `json:"firstname,omitempty"` - Id string `json:"id,omitempty"` - Iscallerchilddomain bool `json:"iscallerchilddomain,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Lastname string `json:"lastname,omitempty"` - Secretkey string `json:"secretkey,omitempty"` - State string `json:"state,omitempty"` - Timezone string `json:"timezone,omitempty"` - Username string `json:"username,omitempty"` -} - -type EnableUserParams struct { - p map[string]interface{} -} - -func (p *EnableUserParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *EnableUserParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new EnableUserParams instance, -// as then you are sure you have configured all required params -func (s *UserService) NewEnableUserParams(id string) *EnableUserParams { - p := &EnableUserParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Enables a user account -func (s *UserService) EnableUser(p *EnableUserParams) (*EnableUserResponse, error) { - resp, err := s.cs.newRequest("enableUser", p.toURLValues()) - if err != nil { - return nil, err - } - - var r EnableUserResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type EnableUserResponse struct { - Account string `json:"account,omitempty"` - Accountid string `json:"accountid,omitempty"` - Accounttype int `json:"accounttype,omitempty"` - Apikey string `json:"apikey,omitempty"` - Created string `json:"created,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Email string `json:"email,omitempty"` - Firstname string `json:"firstname,omitempty"` - Id string `json:"id,omitempty"` - Iscallerchilddomain bool `json:"iscallerchilddomain,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Lastname string `json:"lastname,omitempty"` - Secretkey string `json:"secretkey,omitempty"` - State string `json:"state,omitempty"` - Timezone string `json:"timezone,omitempty"` - Username string `json:"username,omitempty"` -} - -type GetUserParams struct { - p map[string]interface{} -} - -func (p *GetUserParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["userapikey"]; found { - u.Set("userapikey", v.(string)) - } - return u -} - -func (p *GetUserParams) SetUserapikey(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["userapikey"] = v - return -} - -// You should always use this function to get a new GetUserParams instance, -// as then you are sure you have configured all required params -func (s *UserService) NewGetUserParams(userapikey string) *GetUserParams { - p := &GetUserParams{} - p.p = make(map[string]interface{}) - p.p["userapikey"] = userapikey - return p -} - -// Find user account by API key -func (s *UserService) GetUser(p *GetUserParams) (*GetUserResponse, error) { - resp, err := s.cs.newRequest("getUser", p.toURLValues()) - if err != nil { - return nil, err - } - - var r GetUserResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type GetUserResponse struct { - Account string `json:"account,omitempty"` - Accountid string `json:"accountid,omitempty"` - Accounttype int `json:"accounttype,omitempty"` - Apikey string `json:"apikey,omitempty"` - Created string `json:"created,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Email string `json:"email,omitempty"` - Firstname string `json:"firstname,omitempty"` - Id string `json:"id,omitempty"` - Iscallerchilddomain bool `json:"iscallerchilddomain,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Lastname string `json:"lastname,omitempty"` - Secretkey string `json:"secretkey,omitempty"` - State string `json:"state,omitempty"` - Timezone string `json:"timezone,omitempty"` - Username string `json:"username,omitempty"` -} - -type GetVirtualMachineUserDataParams struct { - p map[string]interface{} -} - -func (p *GetVirtualMachineUserDataParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["virtualmachineid"]; found { - u.Set("virtualmachineid", v.(string)) - } - return u -} - -func (p *GetVirtualMachineUserDataParams) SetVirtualmachineid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["virtualmachineid"] = v - return -} - -// You should always use this function to get a new GetVirtualMachineUserDataParams instance, -// as then you are sure you have configured all required params -func (s *UserService) NewGetVirtualMachineUserDataParams(virtualmachineid string) *GetVirtualMachineUserDataParams { - p := &GetVirtualMachineUserDataParams{} - p.p = make(map[string]interface{}) - p.p["virtualmachineid"] = virtualmachineid - return p -} - -// Returns user data associated with the VM -func (s *UserService) GetVirtualMachineUserData(p *GetVirtualMachineUserDataParams) (*GetVirtualMachineUserDataResponse, error) { - resp, err := s.cs.newRequest("getVirtualMachineUserData", p.toURLValues()) - if err != nil { - return nil, err - } - - var r GetVirtualMachineUserDataResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type GetVirtualMachineUserDataResponse struct { - Userdata string `json:"userdata,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` -} - -type RegisterUserKeysParams struct { - p map[string]interface{} -} - -func (p *RegisterUserKeysParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *RegisterUserKeysParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new RegisterUserKeysParams instance, -// as then you are sure you have configured all required params -func (s *UserService) NewRegisterUserKeysParams(id string) *RegisterUserKeysParams { - p := &RegisterUserKeysParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// This command allows a user to register for the developer API, returning a secret key and an API key. This request is made through the integration API port, so it is a privileged command and must be made on behalf of a user. It is up to the implementer just how the username and password are entered, and then how that translates to an integration API request. Both secret key and API key should be returned to the user -func (s *UserService) RegisterUserKeys(p *RegisterUserKeysParams) (*RegisterUserKeysResponse, error) { - resp, err := s.cs.newRequest("registerUserKeys", p.toURLValues()) - if err != nil { - return nil, err - } - - var r RegisterUserKeysResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type RegisterUserKeysResponse struct { - Apikey string `json:"apikey,omitempty"` - Secretkey string `json:"secretkey,omitempty"` -} - -type ListLdapUsersParams struct { - p map[string]interface{} -} - -func (p *ListLdapUsersParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listtype"]; found { - u.Set("listtype", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - return u -} - -func (p *ListLdapUsersParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListLdapUsersParams) SetListtype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listtype"] = v - return -} - -func (p *ListLdapUsersParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListLdapUsersParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -// You should always use this function to get a new ListLdapUsersParams instance, -// as then you are sure you have configured all required params -func (s *UserService) NewListLdapUsersParams() *ListLdapUsersParams { - p := &ListLdapUsersParams{} - p.p = make(map[string]interface{}) - return p -} - -// Lists all LDAP Users -func (s *UserService) ListLdapUsers(p *ListLdapUsersParams) (*ListLdapUsersResponse, error) { - resp, err := s.cs.newRequest("listLdapUsers", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListLdapUsersResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListLdapUsersResponse struct { - Count int `json:"count"` - LdapUsers []*LdapUser `json:"ldapuser"` -} - -type LdapUser struct { - Domain string `json:"domain,omitempty"` - Email string `json:"email,omitempty"` - Firstname string `json:"firstname,omitempty"` - Lastname string `json:"lastname,omitempty"` - Principal string `json:"principal,omitempty"` - Username string `json:"username,omitempty"` -} - -type ImportLdapUsersParams struct { - p map[string]interface{} -} - -func (p *ImportLdapUsersParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["accountdetails"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("accountdetails[%d].key", i), k) - u.Set(fmt.Sprintf("accountdetails[%d].value", i), vv) - i++ - } - } - if v, found := p.p["accounttype"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("accounttype", vv) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["group"]; found { - u.Set("group", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["timezone"]; found { - u.Set("timezone", v.(string)) - } - return u -} - -func (p *ImportLdapUsersParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ImportLdapUsersParams) SetAccountdetails(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["accountdetails"] = v - return -} - -func (p *ImportLdapUsersParams) SetAccounttype(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["accounttype"] = v - return -} - -func (p *ImportLdapUsersParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ImportLdapUsersParams) SetGroup(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["group"] = v - return -} - -func (p *ImportLdapUsersParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ImportLdapUsersParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ImportLdapUsersParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ImportLdapUsersParams) SetTimezone(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["timezone"] = v - return -} - -// You should always use this function to get a new ImportLdapUsersParams instance, -// as then you are sure you have configured all required params -func (s *UserService) NewImportLdapUsersParams(accounttype int) *ImportLdapUsersParams { - p := &ImportLdapUsersParams{} - p.p = make(map[string]interface{}) - p.p["accounttype"] = accounttype - return p -} - -// Import LDAP users -func (s *UserService) ImportLdapUsers(p *ImportLdapUsersParams) (*ImportLdapUsersResponse, error) { - resp, err := s.cs.newRequest("importLdapUsers", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ImportLdapUsersResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ImportLdapUsersResponse struct { - Domain string `json:"domain,omitempty"` - Email string `json:"email,omitempty"` - Firstname string `json:"firstname,omitempty"` - Lastname string `json:"lastname,omitempty"` - Principal string `json:"principal,omitempty"` - Username string `json:"username,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/VLANService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/VLANService.go deleted file mode 100644 index 0809b6dae85..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/VLANService.go +++ /dev/null @@ -1,934 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type CreateVlanIpRangeParams struct { - p map[string]interface{} -} - -func (p *CreateVlanIpRangeParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["endip"]; found { - u.Set("endip", v.(string)) - } - if v, found := p.p["endipv6"]; found { - u.Set("endipv6", v.(string)) - } - if v, found := p.p["forvirtualnetwork"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("forvirtualnetwork", vv) - } - if v, found := p.p["gateway"]; found { - u.Set("gateway", v.(string)) - } - if v, found := p.p["ip6cidr"]; found { - u.Set("ip6cidr", v.(string)) - } - if v, found := p.p["ip6gateway"]; found { - u.Set("ip6gateway", v.(string)) - } - if v, found := p.p["netmask"]; found { - u.Set("netmask", v.(string)) - } - if v, found := p.p["networkid"]; found { - u.Set("networkid", v.(string)) - } - if v, found := p.p["physicalnetworkid"]; found { - u.Set("physicalnetworkid", v.(string)) - } - if v, found := p.p["podid"]; found { - u.Set("podid", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["startip"]; found { - u.Set("startip", v.(string)) - } - if v, found := p.p["startipv6"]; found { - u.Set("startipv6", v.(string)) - } - if v, found := p.p["vlan"]; found { - u.Set("vlan", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *CreateVlanIpRangeParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *CreateVlanIpRangeParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *CreateVlanIpRangeParams) SetEndip(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["endip"] = v - return -} - -func (p *CreateVlanIpRangeParams) SetEndipv6(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["endipv6"] = v - return -} - -func (p *CreateVlanIpRangeParams) SetForvirtualnetwork(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["forvirtualnetwork"] = v - return -} - -func (p *CreateVlanIpRangeParams) SetGateway(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["gateway"] = v - return -} - -func (p *CreateVlanIpRangeParams) SetIp6cidr(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ip6cidr"] = v - return -} - -func (p *CreateVlanIpRangeParams) SetIp6gateway(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ip6gateway"] = v - return -} - -func (p *CreateVlanIpRangeParams) SetNetmask(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["netmask"] = v - return -} - -func (p *CreateVlanIpRangeParams) SetNetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkid"] = v - return -} - -func (p *CreateVlanIpRangeParams) SetPhysicalnetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["physicalnetworkid"] = v - return -} - -func (p *CreateVlanIpRangeParams) SetPodid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["podid"] = v - return -} - -func (p *CreateVlanIpRangeParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *CreateVlanIpRangeParams) SetStartip(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["startip"] = v - return -} - -func (p *CreateVlanIpRangeParams) SetStartipv6(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["startipv6"] = v - return -} - -func (p *CreateVlanIpRangeParams) SetVlan(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vlan"] = v - return -} - -func (p *CreateVlanIpRangeParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new CreateVlanIpRangeParams instance, -// as then you are sure you have configured all required params -func (s *VLANService) NewCreateVlanIpRangeParams() *CreateVlanIpRangeParams { - p := &CreateVlanIpRangeParams{} - p.p = make(map[string]interface{}) - return p -} - -// Creates a VLAN IP range. -func (s *VLANService) CreateVlanIpRange(p *CreateVlanIpRangeParams) (*CreateVlanIpRangeResponse, error) { - resp, err := s.cs.newRequest("createVlanIpRange", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateVlanIpRangeResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type CreateVlanIpRangeResponse struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Endip string `json:"endip,omitempty"` - Endipv6 string `json:"endipv6,omitempty"` - Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Startip string `json:"startip,omitempty"` - Startipv6 string `json:"startipv6,omitempty"` - Vlan string `json:"vlan,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type DeleteVlanIpRangeParams struct { - p map[string]interface{} -} - -func (p *DeleteVlanIpRangeParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteVlanIpRangeParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteVlanIpRangeParams instance, -// as then you are sure you have configured all required params -func (s *VLANService) NewDeleteVlanIpRangeParams(id string) *DeleteVlanIpRangeParams { - p := &DeleteVlanIpRangeParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Creates a VLAN IP range. -func (s *VLANService) DeleteVlanIpRange(p *DeleteVlanIpRangeParams) (*DeleteVlanIpRangeResponse, error) { - resp, err := s.cs.newRequest("deleteVlanIpRange", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteVlanIpRangeResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type DeleteVlanIpRangeResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} - -type ListVlanIpRangesParams struct { - p map[string]interface{} -} - -func (p *ListVlanIpRangesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["forvirtualnetwork"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("forvirtualnetwork", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["networkid"]; found { - u.Set("networkid", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["physicalnetworkid"]; found { - u.Set("physicalnetworkid", v.(string)) - } - if v, found := p.p["podid"]; found { - u.Set("podid", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["vlan"]; found { - u.Set("vlan", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ListVlanIpRangesParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListVlanIpRangesParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListVlanIpRangesParams) SetForvirtualnetwork(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["forvirtualnetwork"] = v - return -} - -func (p *ListVlanIpRangesParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListVlanIpRangesParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListVlanIpRangesParams) SetNetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkid"] = v - return -} - -func (p *ListVlanIpRangesParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListVlanIpRangesParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListVlanIpRangesParams) SetPhysicalnetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["physicalnetworkid"] = v - return -} - -func (p *ListVlanIpRangesParams) SetPodid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["podid"] = v - return -} - -func (p *ListVlanIpRangesParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListVlanIpRangesParams) SetVlan(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vlan"] = v - return -} - -func (p *ListVlanIpRangesParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ListVlanIpRangesParams instance, -// as then you are sure you have configured all required params -func (s *VLANService) NewListVlanIpRangesParams() *ListVlanIpRangesParams { - p := &ListVlanIpRangesParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *VLANService) GetVlanIpRangeByID(id string, opts ...OptionFunc) (*VlanIpRange, int, error) { - p := &ListVlanIpRangesParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListVlanIpRanges(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.VlanIpRanges[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for VlanIpRange UUID: %s!", id) -} - -// Lists all VLAN IP ranges. -func (s *VLANService) ListVlanIpRanges(p *ListVlanIpRangesParams) (*ListVlanIpRangesResponse, error) { - resp, err := s.cs.newRequest("listVlanIpRanges", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListVlanIpRangesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListVlanIpRangesResponse struct { - Count int `json:"count"` - VlanIpRanges []*VlanIpRange `json:"vlaniprange"` -} - -type VlanIpRange struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Endip string `json:"endip,omitempty"` - Endipv6 string `json:"endipv6,omitempty"` - Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Startip string `json:"startip,omitempty"` - Startipv6 string `json:"startipv6,omitempty"` - Vlan string `json:"vlan,omitempty"` - Zoneid string `json:"zoneid,omitempty"` -} - -type DedicateGuestVlanRangeParams struct { - p map[string]interface{} -} - -func (p *DedicateGuestVlanRangeParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["physicalnetworkid"]; found { - u.Set("physicalnetworkid", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["vlanrange"]; found { - u.Set("vlanrange", v.(string)) - } - return u -} - -func (p *DedicateGuestVlanRangeParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *DedicateGuestVlanRangeParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *DedicateGuestVlanRangeParams) SetPhysicalnetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["physicalnetworkid"] = v - return -} - -func (p *DedicateGuestVlanRangeParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *DedicateGuestVlanRangeParams) SetVlanrange(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vlanrange"] = v - return -} - -// You should always use this function to get a new DedicateGuestVlanRangeParams instance, -// as then you are sure you have configured all required params -func (s *VLANService) NewDedicateGuestVlanRangeParams(account string, domainid string, physicalnetworkid string, vlanrange string) *DedicateGuestVlanRangeParams { - p := &DedicateGuestVlanRangeParams{} - p.p = make(map[string]interface{}) - p.p["account"] = account - p.p["domainid"] = domainid - p.p["physicalnetworkid"] = physicalnetworkid - p.p["vlanrange"] = vlanrange - return p -} - -// Dedicates a guest vlan range to an account -func (s *VLANService) DedicateGuestVlanRange(p *DedicateGuestVlanRangeParams) (*DedicateGuestVlanRangeResponse, error) { - resp, err := s.cs.newRequest("dedicateGuestVlanRange", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DedicateGuestVlanRangeResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type DedicateGuestVlanRangeResponse struct { - Account string `json:"account,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Guestvlanrange string `json:"guestvlanrange,omitempty"` - Id string `json:"id,omitempty"` - Physicalnetworkid int64 `json:"physicalnetworkid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Zoneid int64 `json:"zoneid,omitempty"` -} - -type ReleaseDedicatedGuestVlanRangeParams struct { - p map[string]interface{} -} - -func (p *ReleaseDedicatedGuestVlanRangeParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *ReleaseDedicatedGuestVlanRangeParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new ReleaseDedicatedGuestVlanRangeParams instance, -// as then you are sure you have configured all required params -func (s *VLANService) NewReleaseDedicatedGuestVlanRangeParams(id string) *ReleaseDedicatedGuestVlanRangeParams { - p := &ReleaseDedicatedGuestVlanRangeParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Releases a dedicated guest vlan range to the system -func (s *VLANService) ReleaseDedicatedGuestVlanRange(p *ReleaseDedicatedGuestVlanRangeParams) (*ReleaseDedicatedGuestVlanRangeResponse, error) { - resp, err := s.cs.newRequest("releaseDedicatedGuestVlanRange", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ReleaseDedicatedGuestVlanRangeResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type ReleaseDedicatedGuestVlanRangeResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListDedicatedGuestVlanRangesParams struct { - p map[string]interface{} -} - -func (p *ListDedicatedGuestVlanRangesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["guestvlanrange"]; found { - u.Set("guestvlanrange", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["physicalnetworkid"]; found { - u.Set("physicalnetworkid", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ListDedicatedGuestVlanRangesParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListDedicatedGuestVlanRangesParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListDedicatedGuestVlanRangesParams) SetGuestvlanrange(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["guestvlanrange"] = v - return -} - -func (p *ListDedicatedGuestVlanRangesParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListDedicatedGuestVlanRangesParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListDedicatedGuestVlanRangesParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListDedicatedGuestVlanRangesParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListDedicatedGuestVlanRangesParams) SetPhysicalnetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["physicalnetworkid"] = v - return -} - -func (p *ListDedicatedGuestVlanRangesParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListDedicatedGuestVlanRangesParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ListDedicatedGuestVlanRangesParams instance, -// as then you are sure you have configured all required params -func (s *VLANService) NewListDedicatedGuestVlanRangesParams() *ListDedicatedGuestVlanRangesParams { - p := &ListDedicatedGuestVlanRangesParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *VLANService) GetDedicatedGuestVlanRangeByID(id string, opts ...OptionFunc) (*DedicatedGuestVlanRange, int, error) { - p := &ListDedicatedGuestVlanRangesParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListDedicatedGuestVlanRanges(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.DedicatedGuestVlanRanges[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for DedicatedGuestVlanRange UUID: %s!", id) -} - -// Lists dedicated guest vlan ranges -func (s *VLANService) ListDedicatedGuestVlanRanges(p *ListDedicatedGuestVlanRangesParams) (*ListDedicatedGuestVlanRangesResponse, error) { - resp, err := s.cs.newRequest("listDedicatedGuestVlanRanges", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListDedicatedGuestVlanRangesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListDedicatedGuestVlanRangesResponse struct { - Count int `json:"count"` - DedicatedGuestVlanRanges []*DedicatedGuestVlanRange `json:"dedicatedguestvlanrange"` -} - -type DedicatedGuestVlanRange struct { - Account string `json:"account,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Guestvlanrange string `json:"guestvlanrange,omitempty"` - Id string `json:"id,omitempty"` - Physicalnetworkid int64 `json:"physicalnetworkid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Zoneid int64 `json:"zoneid,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/VMGroupService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/VMGroupService.go deleted file mode 100644 index d667684477a..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/VMGroupService.go +++ /dev/null @@ -1,481 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type CreateInstanceGroupParams struct { - p map[string]interface{} -} - -func (p *CreateInstanceGroupParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - return u -} - -func (p *CreateInstanceGroupParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *CreateInstanceGroupParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *CreateInstanceGroupParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *CreateInstanceGroupParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -// You should always use this function to get a new CreateInstanceGroupParams instance, -// as then you are sure you have configured all required params -func (s *VMGroupService) NewCreateInstanceGroupParams(name string) *CreateInstanceGroupParams { - p := &CreateInstanceGroupParams{} - p.p = make(map[string]interface{}) - p.p["name"] = name - return p -} - -// Creates a vm group -func (s *VMGroupService) CreateInstanceGroup(p *CreateInstanceGroupParams) (*CreateInstanceGroupResponse, error) { - resp, err := s.cs.newRequest("createInstanceGroup", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateInstanceGroupResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type CreateInstanceGroupResponse struct { - Account string `json:"account,omitempty"` - Created string `json:"created,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` -} - -type DeleteInstanceGroupParams struct { - p map[string]interface{} -} - -func (p *DeleteInstanceGroupParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteInstanceGroupParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteInstanceGroupParams instance, -// as then you are sure you have configured all required params -func (s *VMGroupService) NewDeleteInstanceGroupParams(id string) *DeleteInstanceGroupParams { - p := &DeleteInstanceGroupParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a vm group -func (s *VMGroupService) DeleteInstanceGroup(p *DeleteInstanceGroupParams) (*DeleteInstanceGroupResponse, error) { - resp, err := s.cs.newRequest("deleteInstanceGroup", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteInstanceGroupResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type DeleteInstanceGroupResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} - -type UpdateInstanceGroupParams struct { - p map[string]interface{} -} - -func (p *UpdateInstanceGroupParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - return u -} - -func (p *UpdateInstanceGroupParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateInstanceGroupParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -// You should always use this function to get a new UpdateInstanceGroupParams instance, -// as then you are sure you have configured all required params -func (s *VMGroupService) NewUpdateInstanceGroupParams(id string) *UpdateInstanceGroupParams { - p := &UpdateInstanceGroupParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates a vm group -func (s *VMGroupService) UpdateInstanceGroup(p *UpdateInstanceGroupParams) (*UpdateInstanceGroupResponse, error) { - resp, err := s.cs.newRequest("updateInstanceGroup", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateInstanceGroupResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type UpdateInstanceGroupResponse struct { - Account string `json:"account,omitempty"` - Created string `json:"created,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` -} - -type ListInstanceGroupsParams struct { - p map[string]interface{} -} - -func (p *ListInstanceGroupsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - return u -} - -func (p *ListInstanceGroupsParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListInstanceGroupsParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListInstanceGroupsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListInstanceGroupsParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListInstanceGroupsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListInstanceGroupsParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListInstanceGroupsParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListInstanceGroupsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListInstanceGroupsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListInstanceGroupsParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -// You should always use this function to get a new ListInstanceGroupsParams instance, -// as then you are sure you have configured all required params -func (s *VMGroupService) NewListInstanceGroupsParams() *ListInstanceGroupsParams { - p := &ListInstanceGroupsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *VMGroupService) GetInstanceGroupID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListInstanceGroupsParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListInstanceGroups(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.InstanceGroups[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.InstanceGroups { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *VMGroupService) GetInstanceGroupByName(name string, opts ...OptionFunc) (*InstanceGroup, int, error) { - id, count, err := s.GetInstanceGroupID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetInstanceGroupByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *VMGroupService) GetInstanceGroupByID(id string, opts ...OptionFunc) (*InstanceGroup, int, error) { - p := &ListInstanceGroupsParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListInstanceGroups(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.InstanceGroups[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for InstanceGroup UUID: %s!", id) -} - -// Lists vm groups -func (s *VMGroupService) ListInstanceGroups(p *ListInstanceGroupsParams) (*ListInstanceGroupsResponse, error) { - resp, err := s.cs.newRequest("listInstanceGroups", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListInstanceGroupsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListInstanceGroupsResponse struct { - Count int `json:"count"` - InstanceGroups []*InstanceGroup `json:"instancegroup"` -} - -type InstanceGroup struct { - Account string `json:"account,omitempty"` - Created string `json:"created,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/VPCService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/VPCService.go deleted file mode 100644 index 86d8a594820..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/VPCService.go +++ /dev/null @@ -1,2843 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type CreateVPCParams struct { - p map[string]interface{} -} - -func (p *CreateVPCParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["cidr"]; found { - u.Set("cidr", v.(string)) - } - if v, found := p.p["displaytext"]; found { - u.Set("displaytext", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["networkdomain"]; found { - u.Set("networkdomain", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["start"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("start", vv) - } - if v, found := p.p["vpcofferingid"]; found { - u.Set("vpcofferingid", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *CreateVPCParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *CreateVPCParams) SetCidr(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["cidr"] = v - return -} - -func (p *CreateVPCParams) SetDisplaytext(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displaytext"] = v - return -} - -func (p *CreateVPCParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *CreateVPCParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *CreateVPCParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *CreateVPCParams) SetNetworkdomain(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkdomain"] = v - return -} - -func (p *CreateVPCParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *CreateVPCParams) SetStart(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["start"] = v - return -} - -func (p *CreateVPCParams) SetVpcofferingid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vpcofferingid"] = v - return -} - -func (p *CreateVPCParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new CreateVPCParams instance, -// as then you are sure you have configured all required params -func (s *VPCService) NewCreateVPCParams(cidr string, displaytext string, name string, vpcofferingid string, zoneid string) *CreateVPCParams { - p := &CreateVPCParams{} - p.p = make(map[string]interface{}) - p.p["cidr"] = cidr - p.p["displaytext"] = displaytext - p.p["name"] = name - p.p["vpcofferingid"] = vpcofferingid - p.p["zoneid"] = zoneid - return p -} - -// Creates a VPC -func (s *VPCService) CreateVPC(p *CreateVPCParams) (*CreateVPCResponse, error) { - resp, err := s.cs.newRequest("createVPC", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateVPCResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateVPCResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Created string `json:"created,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Distributedvpcrouter bool `json:"distributedvpcrouter,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Network []struct { - Account string `json:"account,omitempty"` - Aclid string `json:"aclid,omitempty"` - Acltype string `json:"acltype,omitempty"` - Broadcastdomaintype string `json:"broadcastdomaintype,omitempty"` - Broadcasturi string `json:"broadcasturi,omitempty"` - Canusefordeploy bool `json:"canusefordeploy,omitempty"` - Cidr string `json:"cidr,omitempty"` - Displaynetwork bool `json:"displaynetwork,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Dns1 string `json:"dns1,omitempty"` - Dns2 string `json:"dns2,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Ispersistent bool `json:"ispersistent,omitempty"` - Issystem bool `json:"issystem,omitempty"` - Name string `json:"name,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkcidr string `json:"networkcidr,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Networkofferingavailability string `json:"networkofferingavailability,omitempty"` - Networkofferingconservemode bool `json:"networkofferingconservemode,omitempty"` - Networkofferingdisplaytext string `json:"networkofferingdisplaytext,omitempty"` - Networkofferingid string `json:"networkofferingid,omitempty"` - Networkofferingname string `json:"networkofferingname,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Related string `json:"related,omitempty"` - Reservediprange string `json:"reservediprange,omitempty"` - Restartrequired bool `json:"restartrequired,omitempty"` - Service []struct { - Capability []struct { - Canchooseservicecapability bool `json:"canchooseservicecapability,omitempty"` - Name string `json:"name,omitempty"` - Value string `json:"value,omitempty"` - } `json:"capability,omitempty"` - Name string `json:"name,omitempty"` - Provider []struct { - Canenableindividualservice bool `json:"canenableindividualservice,omitempty"` - Destinationphysicalnetworkid string `json:"destinationphysicalnetworkid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Servicelist []string `json:"servicelist,omitempty"` - State string `json:"state,omitempty"` - } `json:"provider,omitempty"` - } `json:"service,omitempty"` - Specifyipranges bool `json:"specifyipranges,omitempty"` - State string `json:"state,omitempty"` - Strechedl2subnet bool `json:"strechedl2subnet,omitempty"` - Subdomainaccess bool `json:"subdomainaccess,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Vlan string `json:"vlan,omitempty"` - Vpcid string `json:"vpcid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` - Zonesnetworkspans []string `json:"zonesnetworkspans,omitempty"` - } `json:"network,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Redundantvpcrouter bool `json:"redundantvpcrouter,omitempty"` - Regionlevelvpc bool `json:"regionlevelvpc,omitempty"` - Restartrequired bool `json:"restartrequired,omitempty"` - Service []struct { - Capability []struct { - Canchooseservicecapability bool `json:"canchooseservicecapability,omitempty"` - Name string `json:"name,omitempty"` - Value string `json:"value,omitempty"` - } `json:"capability,omitempty"` - Name string `json:"name,omitempty"` - Provider []struct { - Canenableindividualservice bool `json:"canenableindividualservice,omitempty"` - Destinationphysicalnetworkid string `json:"destinationphysicalnetworkid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Servicelist []string `json:"servicelist,omitempty"` - State string `json:"state,omitempty"` - } `json:"provider,omitempty"` - } `json:"service,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Vpcofferingid string `json:"vpcofferingid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type ListVPCsParams struct { - p map[string]interface{} -} - -func (p *ListVPCsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["cidr"]; found { - u.Set("cidr", v.(string)) - } - if v, found := p.p["displaytext"]; found { - u.Set("displaytext", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["restartrequired"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("restartrequired", vv) - } - if v, found := p.p["state"]; found { - u.Set("state", v.(string)) - } - if v, found := p.p["supportedservices"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("supportedservices", vv) - } - if v, found := p.p["tags"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("tags[%d].key", i), k) - u.Set(fmt.Sprintf("tags[%d].value", i), vv) - i++ - } - } - if v, found := p.p["vpcofferingid"]; found { - u.Set("vpcofferingid", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ListVPCsParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListVPCsParams) SetCidr(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["cidr"] = v - return -} - -func (p *ListVPCsParams) SetDisplaytext(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displaytext"] = v - return -} - -func (p *ListVPCsParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListVPCsParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *ListVPCsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListVPCsParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListVPCsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListVPCsParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListVPCsParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListVPCsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListVPCsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListVPCsParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListVPCsParams) SetRestartrequired(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["restartrequired"] = v - return -} - -func (p *ListVPCsParams) SetState(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["state"] = v - return -} - -func (p *ListVPCsParams) SetSupportedservices(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["supportedservices"] = v - return -} - -func (p *ListVPCsParams) SetTags(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tags"] = v - return -} - -func (p *ListVPCsParams) SetVpcofferingid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vpcofferingid"] = v - return -} - -func (p *ListVPCsParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ListVPCsParams instance, -// as then you are sure you have configured all required params -func (s *VPCService) NewListVPCsParams() *ListVPCsParams { - p := &ListVPCsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *VPCService) GetVPCID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListVPCsParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListVPCs(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.VPCs[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.VPCs { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *VPCService) GetVPCByName(name string, opts ...OptionFunc) (*VPC, int, error) { - id, count, err := s.GetVPCID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetVPCByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *VPCService) GetVPCByID(id string, opts ...OptionFunc) (*VPC, int, error) { - p := &ListVPCsParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListVPCs(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.VPCs[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for VPC UUID: %s!", id) -} - -// Lists VPCs -func (s *VPCService) ListVPCs(p *ListVPCsParams) (*ListVPCsResponse, error) { - resp, err := s.cs.newRequest("listVPCs", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListVPCsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListVPCsResponse struct { - Count int `json:"count"` - VPCs []*VPC `json:"vpc"` -} - -type VPC struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Created string `json:"created,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Distributedvpcrouter bool `json:"distributedvpcrouter,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Network []struct { - Account string `json:"account,omitempty"` - Aclid string `json:"aclid,omitempty"` - Acltype string `json:"acltype,omitempty"` - Broadcastdomaintype string `json:"broadcastdomaintype,omitempty"` - Broadcasturi string `json:"broadcasturi,omitempty"` - Canusefordeploy bool `json:"canusefordeploy,omitempty"` - Cidr string `json:"cidr,omitempty"` - Displaynetwork bool `json:"displaynetwork,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Dns1 string `json:"dns1,omitempty"` - Dns2 string `json:"dns2,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Ispersistent bool `json:"ispersistent,omitempty"` - Issystem bool `json:"issystem,omitempty"` - Name string `json:"name,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkcidr string `json:"networkcidr,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Networkofferingavailability string `json:"networkofferingavailability,omitempty"` - Networkofferingconservemode bool `json:"networkofferingconservemode,omitempty"` - Networkofferingdisplaytext string `json:"networkofferingdisplaytext,omitempty"` - Networkofferingid string `json:"networkofferingid,omitempty"` - Networkofferingname string `json:"networkofferingname,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Related string `json:"related,omitempty"` - Reservediprange string `json:"reservediprange,omitempty"` - Restartrequired bool `json:"restartrequired,omitempty"` - Service []struct { - Capability []struct { - Canchooseservicecapability bool `json:"canchooseservicecapability,omitempty"` - Name string `json:"name,omitempty"` - Value string `json:"value,omitempty"` - } `json:"capability,omitempty"` - Name string `json:"name,omitempty"` - Provider []struct { - Canenableindividualservice bool `json:"canenableindividualservice,omitempty"` - Destinationphysicalnetworkid string `json:"destinationphysicalnetworkid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Servicelist []string `json:"servicelist,omitempty"` - State string `json:"state,omitempty"` - } `json:"provider,omitempty"` - } `json:"service,omitempty"` - Specifyipranges bool `json:"specifyipranges,omitempty"` - State string `json:"state,omitempty"` - Strechedl2subnet bool `json:"strechedl2subnet,omitempty"` - Subdomainaccess bool `json:"subdomainaccess,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Vlan string `json:"vlan,omitempty"` - Vpcid string `json:"vpcid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` - Zonesnetworkspans []string `json:"zonesnetworkspans,omitempty"` - } `json:"network,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Redundantvpcrouter bool `json:"redundantvpcrouter,omitempty"` - Regionlevelvpc bool `json:"regionlevelvpc,omitempty"` - Restartrequired bool `json:"restartrequired,omitempty"` - Service []struct { - Capability []struct { - Canchooseservicecapability bool `json:"canchooseservicecapability,omitempty"` - Name string `json:"name,omitempty"` - Value string `json:"value,omitempty"` - } `json:"capability,omitempty"` - Name string `json:"name,omitempty"` - Provider []struct { - Canenableindividualservice bool `json:"canenableindividualservice,omitempty"` - Destinationphysicalnetworkid string `json:"destinationphysicalnetworkid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Servicelist []string `json:"servicelist,omitempty"` - State string `json:"state,omitempty"` - } `json:"provider,omitempty"` - } `json:"service,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Vpcofferingid string `json:"vpcofferingid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type DeleteVPCParams struct { - p map[string]interface{} -} - -func (p *DeleteVPCParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteVPCParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteVPCParams instance, -// as then you are sure you have configured all required params -func (s *VPCService) NewDeleteVPCParams(id string) *DeleteVPCParams { - p := &DeleteVPCParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a VPC -func (s *VPCService) DeleteVPC(p *DeleteVPCParams) (*DeleteVPCResponse, error) { - resp, err := s.cs.newRequest("deleteVPC", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteVPCResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteVPCResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type UpdateVPCParams struct { - p map[string]interface{} -} - -func (p *UpdateVPCParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["customid"]; found { - u.Set("customid", v.(string)) - } - if v, found := p.p["displaytext"]; found { - u.Set("displaytext", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - return u -} - -func (p *UpdateVPCParams) SetCustomid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["customid"] = v - return -} - -func (p *UpdateVPCParams) SetDisplaytext(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displaytext"] = v - return -} - -func (p *UpdateVPCParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *UpdateVPCParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateVPCParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -// You should always use this function to get a new UpdateVPCParams instance, -// as then you are sure you have configured all required params -func (s *VPCService) NewUpdateVPCParams(id string) *UpdateVPCParams { - p := &UpdateVPCParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates a VPC -func (s *VPCService) UpdateVPC(p *UpdateVPCParams) (*UpdateVPCResponse, error) { - resp, err := s.cs.newRequest("updateVPC", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateVPCResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateVPCResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Created string `json:"created,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Distributedvpcrouter bool `json:"distributedvpcrouter,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Network []struct { - Account string `json:"account,omitempty"` - Aclid string `json:"aclid,omitempty"` - Acltype string `json:"acltype,omitempty"` - Broadcastdomaintype string `json:"broadcastdomaintype,omitempty"` - Broadcasturi string `json:"broadcasturi,omitempty"` - Canusefordeploy bool `json:"canusefordeploy,omitempty"` - Cidr string `json:"cidr,omitempty"` - Displaynetwork bool `json:"displaynetwork,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Dns1 string `json:"dns1,omitempty"` - Dns2 string `json:"dns2,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Ispersistent bool `json:"ispersistent,omitempty"` - Issystem bool `json:"issystem,omitempty"` - Name string `json:"name,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkcidr string `json:"networkcidr,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Networkofferingavailability string `json:"networkofferingavailability,omitempty"` - Networkofferingconservemode bool `json:"networkofferingconservemode,omitempty"` - Networkofferingdisplaytext string `json:"networkofferingdisplaytext,omitempty"` - Networkofferingid string `json:"networkofferingid,omitempty"` - Networkofferingname string `json:"networkofferingname,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Related string `json:"related,omitempty"` - Reservediprange string `json:"reservediprange,omitempty"` - Restartrequired bool `json:"restartrequired,omitempty"` - Service []struct { - Capability []struct { - Canchooseservicecapability bool `json:"canchooseservicecapability,omitempty"` - Name string `json:"name,omitempty"` - Value string `json:"value,omitempty"` - } `json:"capability,omitempty"` - Name string `json:"name,omitempty"` - Provider []struct { - Canenableindividualservice bool `json:"canenableindividualservice,omitempty"` - Destinationphysicalnetworkid string `json:"destinationphysicalnetworkid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Servicelist []string `json:"servicelist,omitempty"` - State string `json:"state,omitempty"` - } `json:"provider,omitempty"` - } `json:"service,omitempty"` - Specifyipranges bool `json:"specifyipranges,omitempty"` - State string `json:"state,omitempty"` - Strechedl2subnet bool `json:"strechedl2subnet,omitempty"` - Subdomainaccess bool `json:"subdomainaccess,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Vlan string `json:"vlan,omitempty"` - Vpcid string `json:"vpcid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` - Zonesnetworkspans []string `json:"zonesnetworkspans,omitempty"` - } `json:"network,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Redundantvpcrouter bool `json:"redundantvpcrouter,omitempty"` - Regionlevelvpc bool `json:"regionlevelvpc,omitempty"` - Restartrequired bool `json:"restartrequired,omitempty"` - Service []struct { - Capability []struct { - Canchooseservicecapability bool `json:"canchooseservicecapability,omitempty"` - Name string `json:"name,omitempty"` - Value string `json:"value,omitempty"` - } `json:"capability,omitempty"` - Name string `json:"name,omitempty"` - Provider []struct { - Canenableindividualservice bool `json:"canenableindividualservice,omitempty"` - Destinationphysicalnetworkid string `json:"destinationphysicalnetworkid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Servicelist []string `json:"servicelist,omitempty"` - State string `json:"state,omitempty"` - } `json:"provider,omitempty"` - } `json:"service,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Vpcofferingid string `json:"vpcofferingid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type RestartVPCParams struct { - p map[string]interface{} -} - -func (p *RestartVPCParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["cleanup"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("cleanup", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["makeredundant"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("makeredundant", vv) - } - return u -} - -func (p *RestartVPCParams) SetCleanup(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["cleanup"] = v - return -} - -func (p *RestartVPCParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *RestartVPCParams) SetMakeredundant(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["makeredundant"] = v - return -} - -// You should always use this function to get a new RestartVPCParams instance, -// as then you are sure you have configured all required params -func (s *VPCService) NewRestartVPCParams(id string) *RestartVPCParams { - p := &RestartVPCParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Restarts a VPC -func (s *VPCService) RestartVPC(p *RestartVPCParams) (*RestartVPCResponse, error) { - resp, err := s.cs.newRequest("restartVPC", p.toURLValues()) - if err != nil { - return nil, err - } - - var r RestartVPCResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type RestartVPCResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Created string `json:"created,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Distributedvpcrouter bool `json:"distributedvpcrouter,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Network []struct { - Account string `json:"account,omitempty"` - Aclid string `json:"aclid,omitempty"` - Acltype string `json:"acltype,omitempty"` - Broadcastdomaintype string `json:"broadcastdomaintype,omitempty"` - Broadcasturi string `json:"broadcasturi,omitempty"` - Canusefordeploy bool `json:"canusefordeploy,omitempty"` - Cidr string `json:"cidr,omitempty"` - Displaynetwork bool `json:"displaynetwork,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Dns1 string `json:"dns1,omitempty"` - Dns2 string `json:"dns2,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Ispersistent bool `json:"ispersistent,omitempty"` - Issystem bool `json:"issystem,omitempty"` - Name string `json:"name,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkcidr string `json:"networkcidr,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Networkofferingavailability string `json:"networkofferingavailability,omitempty"` - Networkofferingconservemode bool `json:"networkofferingconservemode,omitempty"` - Networkofferingdisplaytext string `json:"networkofferingdisplaytext,omitempty"` - Networkofferingid string `json:"networkofferingid,omitempty"` - Networkofferingname string `json:"networkofferingname,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Related string `json:"related,omitempty"` - Reservediprange string `json:"reservediprange,omitempty"` - Restartrequired bool `json:"restartrequired,omitempty"` - Service []struct { - Capability []struct { - Canchooseservicecapability bool `json:"canchooseservicecapability,omitempty"` - Name string `json:"name,omitempty"` - Value string `json:"value,omitempty"` - } `json:"capability,omitempty"` - Name string `json:"name,omitempty"` - Provider []struct { - Canenableindividualservice bool `json:"canenableindividualservice,omitempty"` - Destinationphysicalnetworkid string `json:"destinationphysicalnetworkid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Servicelist []string `json:"servicelist,omitempty"` - State string `json:"state,omitempty"` - } `json:"provider,omitempty"` - } `json:"service,omitempty"` - Specifyipranges bool `json:"specifyipranges,omitempty"` - State string `json:"state,omitempty"` - Strechedl2subnet bool `json:"strechedl2subnet,omitempty"` - Subdomainaccess bool `json:"subdomainaccess,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Vlan string `json:"vlan,omitempty"` - Vpcid string `json:"vpcid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` - Zonesnetworkspans []string `json:"zonesnetworkspans,omitempty"` - } `json:"network,omitempty"` - Networkdomain string `json:"networkdomain,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Redundantvpcrouter bool `json:"redundantvpcrouter,omitempty"` - Regionlevelvpc bool `json:"regionlevelvpc,omitempty"` - Restartrequired bool `json:"restartrequired,omitempty"` - Service []struct { - Capability []struct { - Canchooseservicecapability bool `json:"canchooseservicecapability,omitempty"` - Name string `json:"name,omitempty"` - Value string `json:"value,omitempty"` - } `json:"capability,omitempty"` - Name string `json:"name,omitempty"` - Provider []struct { - Canenableindividualservice bool `json:"canenableindividualservice,omitempty"` - Destinationphysicalnetworkid string `json:"destinationphysicalnetworkid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Servicelist []string `json:"servicelist,omitempty"` - State string `json:"state,omitempty"` - } `json:"provider,omitempty"` - } `json:"service,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Vpcofferingid string `json:"vpcofferingid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type CreateVPCOfferingParams struct { - p map[string]interface{} -} - -func (p *CreateVPCOfferingParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["displaytext"]; found { - u.Set("displaytext", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["servicecapabilitylist"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("servicecapabilitylist[%d].key", i), k) - u.Set(fmt.Sprintf("servicecapabilitylist[%d].value", i), vv) - i++ - } - } - if v, found := p.p["serviceofferingid"]; found { - u.Set("serviceofferingid", v.(string)) - } - if v, found := p.p["serviceproviderlist"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("serviceproviderlist[%d].service", i), k) - u.Set(fmt.Sprintf("serviceproviderlist[%d].provider", i), vv) - i++ - } - } - if v, found := p.p["supportedservices"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("supportedservices", vv) - } - return u -} - -func (p *CreateVPCOfferingParams) SetDisplaytext(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displaytext"] = v - return -} - -func (p *CreateVPCOfferingParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *CreateVPCOfferingParams) SetServicecapabilitylist(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["servicecapabilitylist"] = v - return -} - -func (p *CreateVPCOfferingParams) SetServiceofferingid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["serviceofferingid"] = v - return -} - -func (p *CreateVPCOfferingParams) SetServiceproviderlist(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["serviceproviderlist"] = v - return -} - -func (p *CreateVPCOfferingParams) SetSupportedservices(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["supportedservices"] = v - return -} - -// You should always use this function to get a new CreateVPCOfferingParams instance, -// as then you are sure you have configured all required params -func (s *VPCService) NewCreateVPCOfferingParams(displaytext string, name string, supportedservices []string) *CreateVPCOfferingParams { - p := &CreateVPCOfferingParams{} - p.p = make(map[string]interface{}) - p.p["displaytext"] = displaytext - p.p["name"] = name - p.p["supportedservices"] = supportedservices - return p -} - -// Creates VPC offering -func (s *VPCService) CreateVPCOffering(p *CreateVPCOfferingParams) (*CreateVPCOfferingResponse, error) { - resp, err := s.cs.newRequest("createVPCOffering", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateVPCOfferingResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateVPCOfferingResponse struct { - JobID string `json:"jobid,omitempty"` - Created string `json:"created,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Distributedvpcrouter bool `json:"distributedvpcrouter,omitempty"` - Id string `json:"id,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Name string `json:"name,omitempty"` - Service []struct { - Capability []struct { - Canchooseservicecapability bool `json:"canchooseservicecapability,omitempty"` - Name string `json:"name,omitempty"` - Value string `json:"value,omitempty"` - } `json:"capability,omitempty"` - Name string `json:"name,omitempty"` - Provider []struct { - Canenableindividualservice bool `json:"canenableindividualservice,omitempty"` - Destinationphysicalnetworkid string `json:"destinationphysicalnetworkid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Servicelist []string `json:"servicelist,omitempty"` - State string `json:"state,omitempty"` - } `json:"provider,omitempty"` - } `json:"service,omitempty"` - State string `json:"state,omitempty"` - SupportsregionLevelvpc bool `json:"supportsregionLevelvpc,omitempty"` -} - -type UpdateVPCOfferingParams struct { - p map[string]interface{} -} - -func (p *UpdateVPCOfferingParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["displaytext"]; found { - u.Set("displaytext", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["state"]; found { - u.Set("state", v.(string)) - } - return u -} - -func (p *UpdateVPCOfferingParams) SetDisplaytext(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displaytext"] = v - return -} - -func (p *UpdateVPCOfferingParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateVPCOfferingParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *UpdateVPCOfferingParams) SetState(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["state"] = v - return -} - -// You should always use this function to get a new UpdateVPCOfferingParams instance, -// as then you are sure you have configured all required params -func (s *VPCService) NewUpdateVPCOfferingParams(id string) *UpdateVPCOfferingParams { - p := &UpdateVPCOfferingParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates VPC offering -func (s *VPCService) UpdateVPCOffering(p *UpdateVPCOfferingParams) (*UpdateVPCOfferingResponse, error) { - resp, err := s.cs.newRequest("updateVPCOffering", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateVPCOfferingResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateVPCOfferingResponse struct { - JobID string `json:"jobid,omitempty"` - Created string `json:"created,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Distributedvpcrouter bool `json:"distributedvpcrouter,omitempty"` - Id string `json:"id,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Name string `json:"name,omitempty"` - Service []struct { - Capability []struct { - Canchooseservicecapability bool `json:"canchooseservicecapability,omitempty"` - Name string `json:"name,omitempty"` - Value string `json:"value,omitempty"` - } `json:"capability,omitempty"` - Name string `json:"name,omitempty"` - Provider []struct { - Canenableindividualservice bool `json:"canenableindividualservice,omitempty"` - Destinationphysicalnetworkid string `json:"destinationphysicalnetworkid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Servicelist []string `json:"servicelist,omitempty"` - State string `json:"state,omitempty"` - } `json:"provider,omitempty"` - } `json:"service,omitempty"` - State string `json:"state,omitempty"` - SupportsregionLevelvpc bool `json:"supportsregionLevelvpc,omitempty"` -} - -type DeleteVPCOfferingParams struct { - p map[string]interface{} -} - -func (p *DeleteVPCOfferingParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteVPCOfferingParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteVPCOfferingParams instance, -// as then you are sure you have configured all required params -func (s *VPCService) NewDeleteVPCOfferingParams(id string) *DeleteVPCOfferingParams { - p := &DeleteVPCOfferingParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes VPC offering -func (s *VPCService) DeleteVPCOffering(p *DeleteVPCOfferingParams) (*DeleteVPCOfferingResponse, error) { - resp, err := s.cs.newRequest("deleteVPCOffering", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteVPCOfferingResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteVPCOfferingResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListVPCOfferingsParams struct { - p map[string]interface{} -} - -func (p *ListVPCOfferingsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["displaytext"]; found { - u.Set("displaytext", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isdefault"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isdefault", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["state"]; found { - u.Set("state", v.(string)) - } - if v, found := p.p["supportedservices"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("supportedservices", vv) - } - return u -} - -func (p *ListVPCOfferingsParams) SetDisplaytext(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displaytext"] = v - return -} - -func (p *ListVPCOfferingsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListVPCOfferingsParams) SetIsdefault(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isdefault"] = v - return -} - -func (p *ListVPCOfferingsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListVPCOfferingsParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListVPCOfferingsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListVPCOfferingsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListVPCOfferingsParams) SetState(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["state"] = v - return -} - -func (p *ListVPCOfferingsParams) SetSupportedservices(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["supportedservices"] = v - return -} - -// You should always use this function to get a new ListVPCOfferingsParams instance, -// as then you are sure you have configured all required params -func (s *VPCService) NewListVPCOfferingsParams() *ListVPCOfferingsParams { - p := &ListVPCOfferingsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *VPCService) GetVPCOfferingID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListVPCOfferingsParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListVPCOfferings(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.VPCOfferings[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.VPCOfferings { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *VPCService) GetVPCOfferingByName(name string, opts ...OptionFunc) (*VPCOffering, int, error) { - id, count, err := s.GetVPCOfferingID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetVPCOfferingByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *VPCService) GetVPCOfferingByID(id string, opts ...OptionFunc) (*VPCOffering, int, error) { - p := &ListVPCOfferingsParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListVPCOfferings(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.VPCOfferings[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for VPCOffering UUID: %s!", id) -} - -// Lists VPC offerings -func (s *VPCService) ListVPCOfferings(p *ListVPCOfferingsParams) (*ListVPCOfferingsResponse, error) { - resp, err := s.cs.newRequest("listVPCOfferings", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListVPCOfferingsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListVPCOfferingsResponse struct { - Count int `json:"count"` - VPCOfferings []*VPCOffering `json:"vpcoffering"` -} - -type VPCOffering struct { - Created string `json:"created,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Distributedvpcrouter bool `json:"distributedvpcrouter,omitempty"` - Id string `json:"id,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Name string `json:"name,omitempty"` - Service []struct { - Capability []struct { - Canchooseservicecapability bool `json:"canchooseservicecapability,omitempty"` - Name string `json:"name,omitempty"` - Value string `json:"value,omitempty"` - } `json:"capability,omitempty"` - Name string `json:"name,omitempty"` - Provider []struct { - Canenableindividualservice bool `json:"canenableindividualservice,omitempty"` - Destinationphysicalnetworkid string `json:"destinationphysicalnetworkid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Servicelist []string `json:"servicelist,omitempty"` - State string `json:"state,omitempty"` - } `json:"provider,omitempty"` - } `json:"service,omitempty"` - State string `json:"state,omitempty"` - SupportsregionLevelvpc bool `json:"supportsregionLevelvpc,omitempty"` -} - -type CreatePrivateGatewayParams struct { - p map[string]interface{} -} - -func (p *CreatePrivateGatewayParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["aclid"]; found { - u.Set("aclid", v.(string)) - } - if v, found := p.p["gateway"]; found { - u.Set("gateway", v.(string)) - } - if v, found := p.p["ipaddress"]; found { - u.Set("ipaddress", v.(string)) - } - if v, found := p.p["netmask"]; found { - u.Set("netmask", v.(string)) - } - if v, found := p.p["networkofferingid"]; found { - u.Set("networkofferingid", v.(string)) - } - if v, found := p.p["physicalnetworkid"]; found { - u.Set("physicalnetworkid", v.(string)) - } - if v, found := p.p["sourcenatsupported"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("sourcenatsupported", vv) - } - if v, found := p.p["vlan"]; found { - u.Set("vlan", v.(string)) - } - if v, found := p.p["vpcid"]; found { - u.Set("vpcid", v.(string)) - } - return u -} - -func (p *CreatePrivateGatewayParams) SetAclid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["aclid"] = v - return -} - -func (p *CreatePrivateGatewayParams) SetGateway(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["gateway"] = v - return -} - -func (p *CreatePrivateGatewayParams) SetIpaddress(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ipaddress"] = v - return -} - -func (p *CreatePrivateGatewayParams) SetNetmask(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["netmask"] = v - return -} - -func (p *CreatePrivateGatewayParams) SetNetworkofferingid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkofferingid"] = v - return -} - -func (p *CreatePrivateGatewayParams) SetPhysicalnetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["physicalnetworkid"] = v - return -} - -func (p *CreatePrivateGatewayParams) SetSourcenatsupported(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["sourcenatsupported"] = v - return -} - -func (p *CreatePrivateGatewayParams) SetVlan(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vlan"] = v - return -} - -func (p *CreatePrivateGatewayParams) SetVpcid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vpcid"] = v - return -} - -// You should always use this function to get a new CreatePrivateGatewayParams instance, -// as then you are sure you have configured all required params -func (s *VPCService) NewCreatePrivateGatewayParams(gateway string, ipaddress string, netmask string, vlan string, vpcid string) *CreatePrivateGatewayParams { - p := &CreatePrivateGatewayParams{} - p.p = make(map[string]interface{}) - p.p["gateway"] = gateway - p.p["ipaddress"] = ipaddress - p.p["netmask"] = netmask - p.p["vlan"] = vlan - p.p["vpcid"] = vpcid - return p -} - -// Creates a private gateway -func (s *VPCService) CreatePrivateGateway(p *CreatePrivateGatewayParams) (*CreatePrivateGatewayResponse, error) { - resp, err := s.cs.newRequest("createPrivateGateway", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreatePrivateGatewayResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreatePrivateGatewayResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Aclid string `json:"aclid,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Sourcenatsupported bool `json:"sourcenatsupported,omitempty"` - State string `json:"state,omitempty"` - Vlan string `json:"vlan,omitempty"` - Vpcid string `json:"vpcid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type ListPrivateGatewaysParams struct { - p map[string]interface{} -} - -func (p *ListPrivateGatewaysParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["ipaddress"]; found { - u.Set("ipaddress", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["state"]; found { - u.Set("state", v.(string)) - } - if v, found := p.p["vlan"]; found { - u.Set("vlan", v.(string)) - } - if v, found := p.p["vpcid"]; found { - u.Set("vpcid", v.(string)) - } - return u -} - -func (p *ListPrivateGatewaysParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListPrivateGatewaysParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListPrivateGatewaysParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListPrivateGatewaysParams) SetIpaddress(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ipaddress"] = v - return -} - -func (p *ListPrivateGatewaysParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListPrivateGatewaysParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListPrivateGatewaysParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListPrivateGatewaysParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListPrivateGatewaysParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListPrivateGatewaysParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListPrivateGatewaysParams) SetState(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["state"] = v - return -} - -func (p *ListPrivateGatewaysParams) SetVlan(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vlan"] = v - return -} - -func (p *ListPrivateGatewaysParams) SetVpcid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vpcid"] = v - return -} - -// You should always use this function to get a new ListPrivateGatewaysParams instance, -// as then you are sure you have configured all required params -func (s *VPCService) NewListPrivateGatewaysParams() *ListPrivateGatewaysParams { - p := &ListPrivateGatewaysParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *VPCService) GetPrivateGatewayByID(id string, opts ...OptionFunc) (*PrivateGateway, int, error) { - p := &ListPrivateGatewaysParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListPrivateGateways(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.PrivateGateways[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for PrivateGateway UUID: %s!", id) -} - -// List private gateways -func (s *VPCService) ListPrivateGateways(p *ListPrivateGatewaysParams) (*ListPrivateGatewaysResponse, error) { - resp, err := s.cs.newRequest("listPrivateGateways", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListPrivateGatewaysResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListPrivateGatewaysResponse struct { - Count int `json:"count"` - PrivateGateways []*PrivateGateway `json:"privategateway"` -} - -type PrivateGateway struct { - Account string `json:"account,omitempty"` - Aclid string `json:"aclid,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Physicalnetworkid string `json:"physicalnetworkid,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Sourcenatsupported bool `json:"sourcenatsupported,omitempty"` - State string `json:"state,omitempty"` - Vlan string `json:"vlan,omitempty"` - Vpcid string `json:"vpcid,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type DeletePrivateGatewayParams struct { - p map[string]interface{} -} - -func (p *DeletePrivateGatewayParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeletePrivateGatewayParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeletePrivateGatewayParams instance, -// as then you are sure you have configured all required params -func (s *VPCService) NewDeletePrivateGatewayParams(id string) *DeletePrivateGatewayParams { - p := &DeletePrivateGatewayParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a Private gateway -func (s *VPCService) DeletePrivateGateway(p *DeletePrivateGatewayParams) (*DeletePrivateGatewayResponse, error) { - resp, err := s.cs.newRequest("deletePrivateGateway", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeletePrivateGatewayResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeletePrivateGatewayResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type CreateStaticRouteParams struct { - p map[string]interface{} -} - -func (p *CreateStaticRouteParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["cidr"]; found { - u.Set("cidr", v.(string)) - } - if v, found := p.p["gatewayid"]; found { - u.Set("gatewayid", v.(string)) - } - return u -} - -func (p *CreateStaticRouteParams) SetCidr(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["cidr"] = v - return -} - -func (p *CreateStaticRouteParams) SetGatewayid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["gatewayid"] = v - return -} - -// You should always use this function to get a new CreateStaticRouteParams instance, -// as then you are sure you have configured all required params -func (s *VPCService) NewCreateStaticRouteParams(cidr string, gatewayid string) *CreateStaticRouteParams { - p := &CreateStaticRouteParams{} - p.p = make(map[string]interface{}) - p.p["cidr"] = cidr - p.p["gatewayid"] = gatewayid - return p -} - -// Creates a static route -func (s *VPCService) CreateStaticRoute(p *CreateStaticRouteParams) (*CreateStaticRouteResponse, error) { - resp, err := s.cs.newRequest("createStaticRoute", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateStaticRouteResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateStaticRouteResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Gatewayid string `json:"gatewayid,omitempty"` - Id string `json:"id,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Vpcid string `json:"vpcid,omitempty"` -} - -type DeleteStaticRouteParams struct { - p map[string]interface{} -} - -func (p *DeleteStaticRouteParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteStaticRouteParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteStaticRouteParams instance, -// as then you are sure you have configured all required params -func (s *VPCService) NewDeleteStaticRouteParams(id string) *DeleteStaticRouteParams { - p := &DeleteStaticRouteParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a static route -func (s *VPCService) DeleteStaticRoute(p *DeleteStaticRouteParams) (*DeleteStaticRouteResponse, error) { - resp, err := s.cs.newRequest("deleteStaticRoute", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteStaticRouteResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteStaticRouteResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListStaticRoutesParams struct { - p map[string]interface{} -} - -func (p *ListStaticRoutesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["gatewayid"]; found { - u.Set("gatewayid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["tags"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("tags[%d].key", i), k) - u.Set(fmt.Sprintf("tags[%d].value", i), vv) - i++ - } - } - if v, found := p.p["vpcid"]; found { - u.Set("vpcid", v.(string)) - } - return u -} - -func (p *ListStaticRoutesParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListStaticRoutesParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListStaticRoutesParams) SetGatewayid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["gatewayid"] = v - return -} - -func (p *ListStaticRoutesParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListStaticRoutesParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListStaticRoutesParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListStaticRoutesParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListStaticRoutesParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListStaticRoutesParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListStaticRoutesParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListStaticRoutesParams) SetTags(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tags"] = v - return -} - -func (p *ListStaticRoutesParams) SetVpcid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vpcid"] = v - return -} - -// You should always use this function to get a new ListStaticRoutesParams instance, -// as then you are sure you have configured all required params -func (s *VPCService) NewListStaticRoutesParams() *ListStaticRoutesParams { - p := &ListStaticRoutesParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *VPCService) GetStaticRouteByID(id string, opts ...OptionFunc) (*StaticRoute, int, error) { - p := &ListStaticRoutesParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListStaticRoutes(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.StaticRoutes[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for StaticRoute UUID: %s!", id) -} - -// Lists all static routes -func (s *VPCService) ListStaticRoutes(p *ListStaticRoutesParams) (*ListStaticRoutesResponse, error) { - resp, err := s.cs.newRequest("listStaticRoutes", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListStaticRoutesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListStaticRoutesResponse struct { - Count int `json:"count"` - StaticRoutes []*StaticRoute `json:"staticroute"` -} - -type StaticRoute struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Gatewayid string `json:"gatewayid,omitempty"` - Id string `json:"id,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Vpcid string `json:"vpcid,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/VPNService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/VPNService.go deleted file mode 100644 index 544b1732470..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/VPNService.go +++ /dev/null @@ -1,2874 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type CreateRemoteAccessVpnParams struct { - p map[string]interface{} -} - -func (p *CreateRemoteAccessVpnParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["iprange"]; found { - u.Set("iprange", v.(string)) - } - if v, found := p.p["openfirewall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("openfirewall", vv) - } - if v, found := p.p["publicipid"]; found { - u.Set("publicipid", v.(string)) - } - return u -} - -func (p *CreateRemoteAccessVpnParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *CreateRemoteAccessVpnParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *CreateRemoteAccessVpnParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *CreateRemoteAccessVpnParams) SetIprange(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["iprange"] = v - return -} - -func (p *CreateRemoteAccessVpnParams) SetOpenfirewall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["openfirewall"] = v - return -} - -func (p *CreateRemoteAccessVpnParams) SetPublicipid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["publicipid"] = v - return -} - -// You should always use this function to get a new CreateRemoteAccessVpnParams instance, -// as then you are sure you have configured all required params -func (s *VPNService) NewCreateRemoteAccessVpnParams(publicipid string) *CreateRemoteAccessVpnParams { - p := &CreateRemoteAccessVpnParams{} - p.p = make(map[string]interface{}) - p.p["publicipid"] = publicipid - return p -} - -// Creates a l2tp/ipsec remote access vpn -func (s *VPNService) CreateRemoteAccessVpn(p *CreateRemoteAccessVpnParams) (*CreateRemoteAccessVpnResponse, error) { - resp, err := s.cs.newRequest("createRemoteAccessVpn", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateRemoteAccessVpnResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateRemoteAccessVpnResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Iprange string `json:"iprange,omitempty"` - Presharedkey string `json:"presharedkey,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - State string `json:"state,omitempty"` -} - -type DeleteRemoteAccessVpnParams struct { - p map[string]interface{} -} - -func (p *DeleteRemoteAccessVpnParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["publicipid"]; found { - u.Set("publicipid", v.(string)) - } - return u -} - -func (p *DeleteRemoteAccessVpnParams) SetPublicipid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["publicipid"] = v - return -} - -// You should always use this function to get a new DeleteRemoteAccessVpnParams instance, -// as then you are sure you have configured all required params -func (s *VPNService) NewDeleteRemoteAccessVpnParams(publicipid string) *DeleteRemoteAccessVpnParams { - p := &DeleteRemoteAccessVpnParams{} - p.p = make(map[string]interface{}) - p.p["publicipid"] = publicipid - return p -} - -// Destroys a l2tp/ipsec remote access vpn -func (s *VPNService) DeleteRemoteAccessVpn(p *DeleteRemoteAccessVpnParams) (*DeleteRemoteAccessVpnResponse, error) { - resp, err := s.cs.newRequest("deleteRemoteAccessVpn", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteRemoteAccessVpnResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteRemoteAccessVpnResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListRemoteAccessVpnsParams struct { - p map[string]interface{} -} - -func (p *ListRemoteAccessVpnsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["networkid"]; found { - u.Set("networkid", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["publicipid"]; found { - u.Set("publicipid", v.(string)) - } - return u -} - -func (p *ListRemoteAccessVpnsParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListRemoteAccessVpnsParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListRemoteAccessVpnsParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *ListRemoteAccessVpnsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListRemoteAccessVpnsParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListRemoteAccessVpnsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListRemoteAccessVpnsParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListRemoteAccessVpnsParams) SetNetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkid"] = v - return -} - -func (p *ListRemoteAccessVpnsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListRemoteAccessVpnsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListRemoteAccessVpnsParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListRemoteAccessVpnsParams) SetPublicipid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["publicipid"] = v - return -} - -// You should always use this function to get a new ListRemoteAccessVpnsParams instance, -// as then you are sure you have configured all required params -func (s *VPNService) NewListRemoteAccessVpnsParams() *ListRemoteAccessVpnsParams { - p := &ListRemoteAccessVpnsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *VPNService) GetRemoteAccessVpnByID(id string, opts ...OptionFunc) (*RemoteAccessVpn, int, error) { - p := &ListRemoteAccessVpnsParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListRemoteAccessVpns(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.RemoteAccessVpns[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for RemoteAccessVpn UUID: %s!", id) -} - -// Lists remote access vpns -func (s *VPNService) ListRemoteAccessVpns(p *ListRemoteAccessVpnsParams) (*ListRemoteAccessVpnsResponse, error) { - resp, err := s.cs.newRequest("listRemoteAccessVpns", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListRemoteAccessVpnsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListRemoteAccessVpnsResponse struct { - Count int `json:"count"` - RemoteAccessVpns []*RemoteAccessVpn `json:"remoteaccessvpn"` -} - -type RemoteAccessVpn struct { - Account string `json:"account,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Iprange string `json:"iprange,omitempty"` - Presharedkey string `json:"presharedkey,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - State string `json:"state,omitempty"` -} - -type UpdateRemoteAccessVpnParams struct { - p map[string]interface{} -} - -func (p *UpdateRemoteAccessVpnParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["customid"]; found { - u.Set("customid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *UpdateRemoteAccessVpnParams) SetCustomid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["customid"] = v - return -} - -func (p *UpdateRemoteAccessVpnParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *UpdateRemoteAccessVpnParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new UpdateRemoteAccessVpnParams instance, -// as then you are sure you have configured all required params -func (s *VPNService) NewUpdateRemoteAccessVpnParams(id string) *UpdateRemoteAccessVpnParams { - p := &UpdateRemoteAccessVpnParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates remote access vpn -func (s *VPNService) UpdateRemoteAccessVpn(p *UpdateRemoteAccessVpnParams) (*UpdateRemoteAccessVpnResponse, error) { - resp, err := s.cs.newRequest("updateRemoteAccessVpn", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateRemoteAccessVpnResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateRemoteAccessVpnResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Iprange string `json:"iprange,omitempty"` - Presharedkey string `json:"presharedkey,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - State string `json:"state,omitempty"` -} - -type AddVpnUserParams struct { - p map[string]interface{} -} - -func (p *AddVpnUserParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["password"]; found { - u.Set("password", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["username"]; found { - u.Set("username", v.(string)) - } - return u -} - -func (p *AddVpnUserParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *AddVpnUserParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *AddVpnUserParams) SetPassword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["password"] = v - return -} - -func (p *AddVpnUserParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *AddVpnUserParams) SetUsername(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["username"] = v - return -} - -// You should always use this function to get a new AddVpnUserParams instance, -// as then you are sure you have configured all required params -func (s *VPNService) NewAddVpnUserParams(password string, username string) *AddVpnUserParams { - p := &AddVpnUserParams{} - p.p = make(map[string]interface{}) - p.p["password"] = password - p.p["username"] = username - return p -} - -// Adds vpn users -func (s *VPNService) AddVpnUser(p *AddVpnUserParams) (*AddVpnUserResponse, error) { - resp, err := s.cs.newRequest("addVpnUser", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AddVpnUserResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type AddVpnUserResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - State string `json:"state,omitempty"` - Username string `json:"username,omitempty"` -} - -type RemoveVpnUserParams struct { - p map[string]interface{} -} - -func (p *RemoveVpnUserParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["username"]; found { - u.Set("username", v.(string)) - } - return u -} - -func (p *RemoveVpnUserParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *RemoveVpnUserParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *RemoveVpnUserParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *RemoveVpnUserParams) SetUsername(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["username"] = v - return -} - -// You should always use this function to get a new RemoveVpnUserParams instance, -// as then you are sure you have configured all required params -func (s *VPNService) NewRemoveVpnUserParams(username string) *RemoveVpnUserParams { - p := &RemoveVpnUserParams{} - p.p = make(map[string]interface{}) - p.p["username"] = username - return p -} - -// Removes vpn user -func (s *VPNService) RemoveVpnUser(p *RemoveVpnUserParams) (*RemoveVpnUserResponse, error) { - resp, err := s.cs.newRequest("removeVpnUser", p.toURLValues()) - if err != nil { - return nil, err - } - - var r RemoveVpnUserResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type RemoveVpnUserResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListVpnUsersParams struct { - p map[string]interface{} -} - -func (p *ListVpnUsersParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["username"]; found { - u.Set("username", v.(string)) - } - return u -} - -func (p *ListVpnUsersParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListVpnUsersParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListVpnUsersParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListVpnUsersParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListVpnUsersParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListVpnUsersParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListVpnUsersParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListVpnUsersParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListVpnUsersParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListVpnUsersParams) SetUsername(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["username"] = v - return -} - -// You should always use this function to get a new ListVpnUsersParams instance, -// as then you are sure you have configured all required params -func (s *VPNService) NewListVpnUsersParams() *ListVpnUsersParams { - p := &ListVpnUsersParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *VPNService) GetVpnUserByID(id string, opts ...OptionFunc) (*VpnUser, int, error) { - p := &ListVpnUsersParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListVpnUsers(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.VpnUsers[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for VpnUser UUID: %s!", id) -} - -// Lists vpn users -func (s *VPNService) ListVpnUsers(p *ListVpnUsersParams) (*ListVpnUsersResponse, error) { - resp, err := s.cs.newRequest("listVpnUsers", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListVpnUsersResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListVpnUsersResponse struct { - Count int `json:"count"` - VpnUsers []*VpnUser `json:"vpnuser"` -} - -type VpnUser struct { - Account string `json:"account,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - State string `json:"state,omitempty"` - Username string `json:"username,omitempty"` -} - -type CreateVpnCustomerGatewayParams struct { - p map[string]interface{} -} - -func (p *CreateVpnCustomerGatewayParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["cidrlist"]; found { - u.Set("cidrlist", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["dpd"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("dpd", vv) - } - if v, found := p.p["esplifetime"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("esplifetime", vv) - } - if v, found := p.p["esppolicy"]; found { - u.Set("esppolicy", v.(string)) - } - if v, found := p.p["forceencap"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("forceencap", vv) - } - if v, found := p.p["gateway"]; found { - u.Set("gateway", v.(string)) - } - if v, found := p.p["ikelifetime"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("ikelifetime", vv) - } - if v, found := p.p["ikepolicy"]; found { - u.Set("ikepolicy", v.(string)) - } - if v, found := p.p["ipsecpsk"]; found { - u.Set("ipsecpsk", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - return u -} - -func (p *CreateVpnCustomerGatewayParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *CreateVpnCustomerGatewayParams) SetCidrlist(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["cidrlist"] = v - return -} - -func (p *CreateVpnCustomerGatewayParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *CreateVpnCustomerGatewayParams) SetDpd(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["dpd"] = v - return -} - -func (p *CreateVpnCustomerGatewayParams) SetEsplifetime(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["esplifetime"] = v - return -} - -func (p *CreateVpnCustomerGatewayParams) SetEsppolicy(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["esppolicy"] = v - return -} - -func (p *CreateVpnCustomerGatewayParams) SetForceencap(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["forceencap"] = v - return -} - -func (p *CreateVpnCustomerGatewayParams) SetGateway(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["gateway"] = v - return -} - -func (p *CreateVpnCustomerGatewayParams) SetIkelifetime(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ikelifetime"] = v - return -} - -func (p *CreateVpnCustomerGatewayParams) SetIkepolicy(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ikepolicy"] = v - return -} - -func (p *CreateVpnCustomerGatewayParams) SetIpsecpsk(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ipsecpsk"] = v - return -} - -func (p *CreateVpnCustomerGatewayParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *CreateVpnCustomerGatewayParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -// You should always use this function to get a new CreateVpnCustomerGatewayParams instance, -// as then you are sure you have configured all required params -func (s *VPNService) NewCreateVpnCustomerGatewayParams(cidrlist string, esppolicy string, gateway string, ikepolicy string, ipsecpsk string) *CreateVpnCustomerGatewayParams { - p := &CreateVpnCustomerGatewayParams{} - p.p = make(map[string]interface{}) - p.p["cidrlist"] = cidrlist - p.p["esppolicy"] = esppolicy - p.p["gateway"] = gateway - p.p["ikepolicy"] = ikepolicy - p.p["ipsecpsk"] = ipsecpsk - return p -} - -// Creates site to site vpn customer gateway -func (s *VPNService) CreateVpnCustomerGateway(p *CreateVpnCustomerGatewayParams) (*CreateVpnCustomerGatewayResponse, error) { - resp, err := s.cs.newRequest("createVpnCustomerGateway", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateVpnCustomerGatewayResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateVpnCustomerGatewayResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Cidrlist string `json:"cidrlist,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Dpd bool `json:"dpd,omitempty"` - Esplifetime int64 `json:"esplifetime,omitempty"` - Esppolicy string `json:"esppolicy,omitempty"` - Forceencap bool `json:"forceencap,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ikelifetime int64 `json:"ikelifetime,omitempty"` - Ikepolicy string `json:"ikepolicy,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Ipsecpsk string `json:"ipsecpsk,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Removed string `json:"removed,omitempty"` -} - -type CreateVpnGatewayParams struct { - p map[string]interface{} -} - -func (p *CreateVpnGatewayParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["vpcid"]; found { - u.Set("vpcid", v.(string)) - } - return u -} - -func (p *CreateVpnGatewayParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *CreateVpnGatewayParams) SetVpcid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vpcid"] = v - return -} - -// You should always use this function to get a new CreateVpnGatewayParams instance, -// as then you are sure you have configured all required params -func (s *VPNService) NewCreateVpnGatewayParams(vpcid string) *CreateVpnGatewayParams { - p := &CreateVpnGatewayParams{} - p.p = make(map[string]interface{}) - p.p["vpcid"] = vpcid - return p -} - -// Creates site to site vpn local gateway -func (s *VPNService) CreateVpnGateway(p *CreateVpnGatewayParams) (*CreateVpnGatewayResponse, error) { - resp, err := s.cs.newRequest("createVpnGateway", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateVpnGatewayResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateVpnGatewayResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Removed string `json:"removed,omitempty"` - Vpcid string `json:"vpcid,omitempty"` -} - -type CreateVpnConnectionParams struct { - p map[string]interface{} -} - -func (p *CreateVpnConnectionParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["passive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("passive", vv) - } - if v, found := p.p["s2scustomergatewayid"]; found { - u.Set("s2scustomergatewayid", v.(string)) - } - if v, found := p.p["s2svpngatewayid"]; found { - u.Set("s2svpngatewayid", v.(string)) - } - return u -} - -func (p *CreateVpnConnectionParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *CreateVpnConnectionParams) SetPassive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["passive"] = v - return -} - -func (p *CreateVpnConnectionParams) SetS2scustomergatewayid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["s2scustomergatewayid"] = v - return -} - -func (p *CreateVpnConnectionParams) SetS2svpngatewayid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["s2svpngatewayid"] = v - return -} - -// You should always use this function to get a new CreateVpnConnectionParams instance, -// as then you are sure you have configured all required params -func (s *VPNService) NewCreateVpnConnectionParams(s2scustomergatewayid string, s2svpngatewayid string) *CreateVpnConnectionParams { - p := &CreateVpnConnectionParams{} - p.p = make(map[string]interface{}) - p.p["s2scustomergatewayid"] = s2scustomergatewayid - p.p["s2svpngatewayid"] = s2svpngatewayid - return p -} - -// Create site to site vpn connection -func (s *VPNService) CreateVpnConnection(p *CreateVpnConnectionParams) (*CreateVpnConnectionResponse, error) { - resp, err := s.cs.newRequest("createVpnConnection", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateVpnConnectionResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateVpnConnectionResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Cidrlist string `json:"cidrlist,omitempty"` - Created string `json:"created,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Dpd bool `json:"dpd,omitempty"` - Esplifetime int64 `json:"esplifetime,omitempty"` - Esppolicy string `json:"esppolicy,omitempty"` - Forceencap bool `json:"forceencap,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ikelifetime int64 `json:"ikelifetime,omitempty"` - Ikepolicy string `json:"ikepolicy,omitempty"` - Ipsecpsk string `json:"ipsecpsk,omitempty"` - Passive bool `json:"passive,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Removed string `json:"removed,omitempty"` - S2scustomergatewayid string `json:"s2scustomergatewayid,omitempty"` - S2svpngatewayid string `json:"s2svpngatewayid,omitempty"` - State string `json:"state,omitempty"` -} - -type DeleteVpnCustomerGatewayParams struct { - p map[string]interface{} -} - -func (p *DeleteVpnCustomerGatewayParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteVpnCustomerGatewayParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteVpnCustomerGatewayParams instance, -// as then you are sure you have configured all required params -func (s *VPNService) NewDeleteVpnCustomerGatewayParams(id string) *DeleteVpnCustomerGatewayParams { - p := &DeleteVpnCustomerGatewayParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Delete site to site vpn customer gateway -func (s *VPNService) DeleteVpnCustomerGateway(p *DeleteVpnCustomerGatewayParams) (*DeleteVpnCustomerGatewayResponse, error) { - resp, err := s.cs.newRequest("deleteVpnCustomerGateway", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteVpnCustomerGatewayResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteVpnCustomerGatewayResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type DeleteVpnGatewayParams struct { - p map[string]interface{} -} - -func (p *DeleteVpnGatewayParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteVpnGatewayParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteVpnGatewayParams instance, -// as then you are sure you have configured all required params -func (s *VPNService) NewDeleteVpnGatewayParams(id string) *DeleteVpnGatewayParams { - p := &DeleteVpnGatewayParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Delete site to site vpn gateway -func (s *VPNService) DeleteVpnGateway(p *DeleteVpnGatewayParams) (*DeleteVpnGatewayResponse, error) { - resp, err := s.cs.newRequest("deleteVpnGateway", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteVpnGatewayResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteVpnGatewayResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type DeleteVpnConnectionParams struct { - p map[string]interface{} -} - -func (p *DeleteVpnConnectionParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteVpnConnectionParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteVpnConnectionParams instance, -// as then you are sure you have configured all required params -func (s *VPNService) NewDeleteVpnConnectionParams(id string) *DeleteVpnConnectionParams { - p := &DeleteVpnConnectionParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Delete site to site vpn connection -func (s *VPNService) DeleteVpnConnection(p *DeleteVpnConnectionParams) (*DeleteVpnConnectionResponse, error) { - resp, err := s.cs.newRequest("deleteVpnConnection", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteVpnConnectionResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeleteVpnConnectionResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type UpdateVpnCustomerGatewayParams struct { - p map[string]interface{} -} - -func (p *UpdateVpnCustomerGatewayParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["cidrlist"]; found { - u.Set("cidrlist", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["dpd"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("dpd", vv) - } - if v, found := p.p["esplifetime"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("esplifetime", vv) - } - if v, found := p.p["esppolicy"]; found { - u.Set("esppolicy", v.(string)) - } - if v, found := p.p["forceencap"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("forceencap", vv) - } - if v, found := p.p["gateway"]; found { - u.Set("gateway", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["ikelifetime"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("ikelifetime", vv) - } - if v, found := p.p["ikepolicy"]; found { - u.Set("ikepolicy", v.(string)) - } - if v, found := p.p["ipsecpsk"]; found { - u.Set("ipsecpsk", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - return u -} - -func (p *UpdateVpnCustomerGatewayParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *UpdateVpnCustomerGatewayParams) SetCidrlist(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["cidrlist"] = v - return -} - -func (p *UpdateVpnCustomerGatewayParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *UpdateVpnCustomerGatewayParams) SetDpd(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["dpd"] = v - return -} - -func (p *UpdateVpnCustomerGatewayParams) SetEsplifetime(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["esplifetime"] = v - return -} - -func (p *UpdateVpnCustomerGatewayParams) SetEsppolicy(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["esppolicy"] = v - return -} - -func (p *UpdateVpnCustomerGatewayParams) SetForceencap(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["forceencap"] = v - return -} - -func (p *UpdateVpnCustomerGatewayParams) SetGateway(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["gateway"] = v - return -} - -func (p *UpdateVpnCustomerGatewayParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateVpnCustomerGatewayParams) SetIkelifetime(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ikelifetime"] = v - return -} - -func (p *UpdateVpnCustomerGatewayParams) SetIkepolicy(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ikepolicy"] = v - return -} - -func (p *UpdateVpnCustomerGatewayParams) SetIpsecpsk(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ipsecpsk"] = v - return -} - -func (p *UpdateVpnCustomerGatewayParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -// You should always use this function to get a new UpdateVpnCustomerGatewayParams instance, -// as then you are sure you have configured all required params -func (s *VPNService) NewUpdateVpnCustomerGatewayParams(cidrlist string, esppolicy string, gateway string, id string, ikepolicy string, ipsecpsk string) *UpdateVpnCustomerGatewayParams { - p := &UpdateVpnCustomerGatewayParams{} - p.p = make(map[string]interface{}) - p.p["cidrlist"] = cidrlist - p.p["esppolicy"] = esppolicy - p.p["gateway"] = gateway - p.p["id"] = id - p.p["ikepolicy"] = ikepolicy - p.p["ipsecpsk"] = ipsecpsk - return p -} - -// Update site to site vpn customer gateway -func (s *VPNService) UpdateVpnCustomerGateway(p *UpdateVpnCustomerGatewayParams) (*UpdateVpnCustomerGatewayResponse, error) { - resp, err := s.cs.newRequest("updateVpnCustomerGateway", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateVpnCustomerGatewayResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateVpnCustomerGatewayResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Cidrlist string `json:"cidrlist,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Dpd bool `json:"dpd,omitempty"` - Esplifetime int64 `json:"esplifetime,omitempty"` - Esppolicy string `json:"esppolicy,omitempty"` - Forceencap bool `json:"forceencap,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ikelifetime int64 `json:"ikelifetime,omitempty"` - Ikepolicy string `json:"ikepolicy,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Ipsecpsk string `json:"ipsecpsk,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Removed string `json:"removed,omitempty"` -} - -type ResetVpnConnectionParams struct { - p map[string]interface{} -} - -func (p *ResetVpnConnectionParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *ResetVpnConnectionParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ResetVpnConnectionParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ResetVpnConnectionParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new ResetVpnConnectionParams instance, -// as then you are sure you have configured all required params -func (s *VPNService) NewResetVpnConnectionParams(id string) *ResetVpnConnectionParams { - p := &ResetVpnConnectionParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Reset site to site vpn connection -func (s *VPNService) ResetVpnConnection(p *ResetVpnConnectionParams) (*ResetVpnConnectionResponse, error) { - resp, err := s.cs.newRequest("resetVpnConnection", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ResetVpnConnectionResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type ResetVpnConnectionResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Cidrlist string `json:"cidrlist,omitempty"` - Created string `json:"created,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Dpd bool `json:"dpd,omitempty"` - Esplifetime int64 `json:"esplifetime,omitempty"` - Esppolicy string `json:"esppolicy,omitempty"` - Forceencap bool `json:"forceencap,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ikelifetime int64 `json:"ikelifetime,omitempty"` - Ikepolicy string `json:"ikepolicy,omitempty"` - Ipsecpsk string `json:"ipsecpsk,omitempty"` - Passive bool `json:"passive,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Removed string `json:"removed,omitempty"` - S2scustomergatewayid string `json:"s2scustomergatewayid,omitempty"` - S2svpngatewayid string `json:"s2svpngatewayid,omitempty"` - State string `json:"state,omitempty"` -} - -type ListVpnCustomerGatewaysParams struct { - p map[string]interface{} -} - -func (p *ListVpnCustomerGatewaysParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - return u -} - -func (p *ListVpnCustomerGatewaysParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListVpnCustomerGatewaysParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListVpnCustomerGatewaysParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListVpnCustomerGatewaysParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListVpnCustomerGatewaysParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListVpnCustomerGatewaysParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListVpnCustomerGatewaysParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListVpnCustomerGatewaysParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListVpnCustomerGatewaysParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -// You should always use this function to get a new ListVpnCustomerGatewaysParams instance, -// as then you are sure you have configured all required params -func (s *VPNService) NewListVpnCustomerGatewaysParams() *ListVpnCustomerGatewaysParams { - p := &ListVpnCustomerGatewaysParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *VPNService) GetVpnCustomerGatewayID(keyword string, opts ...OptionFunc) (string, int, error) { - p := &ListVpnCustomerGatewaysParams{} - p.p = make(map[string]interface{}) - - p.p["keyword"] = keyword - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListVpnCustomerGateways(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", keyword, l) - } - - if l.Count == 1 { - return l.VpnCustomerGateways[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.VpnCustomerGateways { - if v.Name == keyword { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *VPNService) GetVpnCustomerGatewayByName(name string, opts ...OptionFunc) (*VpnCustomerGateway, int, error) { - id, count, err := s.GetVpnCustomerGatewayID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetVpnCustomerGatewayByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *VPNService) GetVpnCustomerGatewayByID(id string, opts ...OptionFunc) (*VpnCustomerGateway, int, error) { - p := &ListVpnCustomerGatewaysParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListVpnCustomerGateways(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.VpnCustomerGateways[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for VpnCustomerGateway UUID: %s!", id) -} - -// Lists site to site vpn customer gateways -func (s *VPNService) ListVpnCustomerGateways(p *ListVpnCustomerGatewaysParams) (*ListVpnCustomerGatewaysResponse, error) { - resp, err := s.cs.newRequest("listVpnCustomerGateways", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListVpnCustomerGatewaysResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListVpnCustomerGatewaysResponse struct { - Count int `json:"count"` - VpnCustomerGateways []*VpnCustomerGateway `json:"vpncustomergateway"` -} - -type VpnCustomerGateway struct { - Account string `json:"account,omitempty"` - Cidrlist string `json:"cidrlist,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Dpd bool `json:"dpd,omitempty"` - Esplifetime int64 `json:"esplifetime,omitempty"` - Esppolicy string `json:"esppolicy,omitempty"` - Forceencap bool `json:"forceencap,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ikelifetime int64 `json:"ikelifetime,omitempty"` - Ikepolicy string `json:"ikepolicy,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Ipsecpsk string `json:"ipsecpsk,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Removed string `json:"removed,omitempty"` -} - -type ListVpnGatewaysParams struct { - p map[string]interface{} -} - -func (p *ListVpnGatewaysParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["vpcid"]; found { - u.Set("vpcid", v.(string)) - } - return u -} - -func (p *ListVpnGatewaysParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListVpnGatewaysParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListVpnGatewaysParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *ListVpnGatewaysParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListVpnGatewaysParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListVpnGatewaysParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListVpnGatewaysParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListVpnGatewaysParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListVpnGatewaysParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListVpnGatewaysParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListVpnGatewaysParams) SetVpcid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vpcid"] = v - return -} - -// You should always use this function to get a new ListVpnGatewaysParams instance, -// as then you are sure you have configured all required params -func (s *VPNService) NewListVpnGatewaysParams() *ListVpnGatewaysParams { - p := &ListVpnGatewaysParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *VPNService) GetVpnGatewayByID(id string, opts ...OptionFunc) (*VpnGateway, int, error) { - p := &ListVpnGatewaysParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListVpnGateways(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.VpnGateways[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for VpnGateway UUID: %s!", id) -} - -// Lists site 2 site vpn gateways -func (s *VPNService) ListVpnGateways(p *ListVpnGatewaysParams) (*ListVpnGatewaysResponse, error) { - resp, err := s.cs.newRequest("listVpnGateways", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListVpnGatewaysResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListVpnGatewaysResponse struct { - Count int `json:"count"` - VpnGateways []*VpnGateway `json:"vpngateway"` -} - -type VpnGateway struct { - Account string `json:"account,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Removed string `json:"removed,omitempty"` - Vpcid string `json:"vpcid,omitempty"` -} - -type ListVpnConnectionsParams struct { - p map[string]interface{} -} - -func (p *ListVpnConnectionsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["vpcid"]; found { - u.Set("vpcid", v.(string)) - } - return u -} - -func (p *ListVpnConnectionsParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListVpnConnectionsParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListVpnConnectionsParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *ListVpnConnectionsParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListVpnConnectionsParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListVpnConnectionsParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListVpnConnectionsParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListVpnConnectionsParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListVpnConnectionsParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListVpnConnectionsParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListVpnConnectionsParams) SetVpcid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vpcid"] = v - return -} - -// You should always use this function to get a new ListVpnConnectionsParams instance, -// as then you are sure you have configured all required params -func (s *VPNService) NewListVpnConnectionsParams() *ListVpnConnectionsParams { - p := &ListVpnConnectionsParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *VPNService) GetVpnConnectionByID(id string, opts ...OptionFunc) (*VpnConnection, int, error) { - p := &ListVpnConnectionsParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListVpnConnections(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.VpnConnections[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for VpnConnection UUID: %s!", id) -} - -// Lists site to site vpn connection gateways -func (s *VPNService) ListVpnConnections(p *ListVpnConnectionsParams) (*ListVpnConnectionsResponse, error) { - resp, err := s.cs.newRequest("listVpnConnections", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListVpnConnectionsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListVpnConnectionsResponse struct { - Count int `json:"count"` - VpnConnections []*VpnConnection `json:"vpnconnection"` -} - -type VpnConnection struct { - Account string `json:"account,omitempty"` - Cidrlist string `json:"cidrlist,omitempty"` - Created string `json:"created,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Dpd bool `json:"dpd,omitempty"` - Esplifetime int64 `json:"esplifetime,omitempty"` - Esppolicy string `json:"esppolicy,omitempty"` - Forceencap bool `json:"forceencap,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ikelifetime int64 `json:"ikelifetime,omitempty"` - Ikepolicy string `json:"ikepolicy,omitempty"` - Ipsecpsk string `json:"ipsecpsk,omitempty"` - Passive bool `json:"passive,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Removed string `json:"removed,omitempty"` - S2scustomergatewayid string `json:"s2scustomergatewayid,omitempty"` - S2svpngatewayid string `json:"s2svpngatewayid,omitempty"` - State string `json:"state,omitempty"` -} - -type UpdateVpnConnectionParams struct { - p map[string]interface{} -} - -func (p *UpdateVpnConnectionParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["customid"]; found { - u.Set("customid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *UpdateVpnConnectionParams) SetCustomid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["customid"] = v - return -} - -func (p *UpdateVpnConnectionParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *UpdateVpnConnectionParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new UpdateVpnConnectionParams instance, -// as then you are sure you have configured all required params -func (s *VPNService) NewUpdateVpnConnectionParams(id string) *UpdateVpnConnectionParams { - p := &UpdateVpnConnectionParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates site to site vpn connection -func (s *VPNService) UpdateVpnConnection(p *UpdateVpnConnectionParams) (*UpdateVpnConnectionResponse, error) { - resp, err := s.cs.newRequest("updateVpnConnection", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateVpnConnectionResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateVpnConnectionResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Cidrlist string `json:"cidrlist,omitempty"` - Created string `json:"created,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Dpd bool `json:"dpd,omitempty"` - Esplifetime int64 `json:"esplifetime,omitempty"` - Esppolicy string `json:"esppolicy,omitempty"` - Forceencap bool `json:"forceencap,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ikelifetime int64 `json:"ikelifetime,omitempty"` - Ikepolicy string `json:"ikepolicy,omitempty"` - Ipsecpsk string `json:"ipsecpsk,omitempty"` - Passive bool `json:"passive,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Removed string `json:"removed,omitempty"` - S2scustomergatewayid string `json:"s2scustomergatewayid,omitempty"` - S2svpngatewayid string `json:"s2svpngatewayid,omitempty"` - State string `json:"state,omitempty"` -} - -type UpdateVpnGatewayParams struct { - p map[string]interface{} -} - -func (p *UpdateVpnGatewayParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["customid"]; found { - u.Set("customid", v.(string)) - } - if v, found := p.p["fordisplay"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("fordisplay", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *UpdateVpnGatewayParams) SetCustomid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["customid"] = v - return -} - -func (p *UpdateVpnGatewayParams) SetFordisplay(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["fordisplay"] = v - return -} - -func (p *UpdateVpnGatewayParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new UpdateVpnGatewayParams instance, -// as then you are sure you have configured all required params -func (s *VPNService) NewUpdateVpnGatewayParams(id string) *UpdateVpnGatewayParams { - p := &UpdateVpnGatewayParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates site to site vpn local gateway -func (s *VPNService) UpdateVpnGateway(p *UpdateVpnGatewayParams) (*UpdateVpnGatewayResponse, error) { - resp, err := s.cs.newRequest("updateVpnGateway", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateVpnGatewayResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateVpnGatewayResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Fordisplay bool `json:"fordisplay,omitempty"` - Id string `json:"id,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Removed string `json:"removed,omitempty"` - Vpcid string `json:"vpcid,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/VirtualMachineService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/VirtualMachineService.go deleted file mode 100644 index 8be3066f470..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/VirtualMachineService.go +++ /dev/null @@ -1,5445 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type DeployVirtualMachineParams struct { - p map[string]interface{} -} - -func (p *DeployVirtualMachineParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["affinitygroupids"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("affinitygroupids", vv) - } - if v, found := p.p["affinitygroupnames"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("affinitygroupnames", vv) - } - if v, found := p.p["customid"]; found { - u.Set("customid", v.(string)) - } - if v, found := p.p["deploymentplanner"]; found { - u.Set("deploymentplanner", v.(string)) - } - if v, found := p.p["details"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("details[%d].key", i), k) - u.Set(fmt.Sprintf("details[%d].value", i), vv) - i++ - } - } - if v, found := p.p["diskofferingid"]; found { - u.Set("diskofferingid", v.(string)) - } - if v, found := p.p["displayname"]; found { - u.Set("displayname", v.(string)) - } - if v, found := p.p["displayvm"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("displayvm", vv) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["group"]; found { - u.Set("group", v.(string)) - } - if v, found := p.p["hostid"]; found { - u.Set("hostid", v.(string)) - } - if v, found := p.p["hypervisor"]; found { - u.Set("hypervisor", v.(string)) - } - if v, found := p.p["ip6address"]; found { - u.Set("ip6address", v.(string)) - } - if v, found := p.p["ipaddress"]; found { - u.Set("ipaddress", v.(string)) - } - if v, found := p.p["iptonetworklist"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("iptonetworklist[%d].key", i), k) - u.Set(fmt.Sprintf("iptonetworklist[%d].value", i), vv) - i++ - } - } - if v, found := p.p["keyboard"]; found { - u.Set("keyboard", v.(string)) - } - if v, found := p.p["keypair"]; found { - u.Set("keypair", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["networkids"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("networkids", vv) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["rootdisksize"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("rootdisksize", vv) - } - if v, found := p.p["securitygroupids"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("securitygroupids", vv) - } - if v, found := p.p["securitygroupnames"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("securitygroupnames", vv) - } - if v, found := p.p["serviceofferingid"]; found { - u.Set("serviceofferingid", v.(string)) - } - if v, found := p.p["size"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("size", vv) - } - if v, found := p.p["startvm"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("startvm", vv) - } - if v, found := p.p["templateid"]; found { - u.Set("templateid", v.(string)) - } - if v, found := p.p["userdata"]; found { - u.Set("userdata", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *DeployVirtualMachineParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *DeployVirtualMachineParams) SetAffinitygroupids(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["affinitygroupids"] = v - return -} - -func (p *DeployVirtualMachineParams) SetAffinitygroupnames(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["affinitygroupnames"] = v - return -} - -func (p *DeployVirtualMachineParams) SetCustomid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["customid"] = v - return -} - -func (p *DeployVirtualMachineParams) SetDeploymentplanner(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["deploymentplanner"] = v - return -} - -func (p *DeployVirtualMachineParams) SetDetails(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["details"] = v - return -} - -func (p *DeployVirtualMachineParams) SetDiskofferingid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["diskofferingid"] = v - return -} - -func (p *DeployVirtualMachineParams) SetDisplayname(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displayname"] = v - return -} - -func (p *DeployVirtualMachineParams) SetDisplayvm(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displayvm"] = v - return -} - -func (p *DeployVirtualMachineParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *DeployVirtualMachineParams) SetGroup(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["group"] = v - return -} - -func (p *DeployVirtualMachineParams) SetHostid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hostid"] = v - return -} - -func (p *DeployVirtualMachineParams) SetHypervisor(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hypervisor"] = v - return -} - -func (p *DeployVirtualMachineParams) SetIp6address(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ip6address"] = v - return -} - -func (p *DeployVirtualMachineParams) SetIpaddress(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ipaddress"] = v - return -} - -func (p *DeployVirtualMachineParams) SetIptonetworklist(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["iptonetworklist"] = v - return -} - -func (p *DeployVirtualMachineParams) SetKeyboard(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyboard"] = v - return -} - -func (p *DeployVirtualMachineParams) SetKeypair(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keypair"] = v - return -} - -func (p *DeployVirtualMachineParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *DeployVirtualMachineParams) SetNetworkids(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkids"] = v - return -} - -func (p *DeployVirtualMachineParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *DeployVirtualMachineParams) SetRootdisksize(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["rootdisksize"] = v - return -} - -func (p *DeployVirtualMachineParams) SetSecuritygroupids(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["securitygroupids"] = v - return -} - -func (p *DeployVirtualMachineParams) SetSecuritygroupnames(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["securitygroupnames"] = v - return -} - -func (p *DeployVirtualMachineParams) SetServiceofferingid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["serviceofferingid"] = v - return -} - -func (p *DeployVirtualMachineParams) SetSize(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["size"] = v - return -} - -func (p *DeployVirtualMachineParams) SetStartvm(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["startvm"] = v - return -} - -func (p *DeployVirtualMachineParams) SetTemplateid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["templateid"] = v - return -} - -func (p *DeployVirtualMachineParams) SetUserdata(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["userdata"] = v - return -} - -func (p *DeployVirtualMachineParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new DeployVirtualMachineParams instance, -// as then you are sure you have configured all required params -func (s *VirtualMachineService) NewDeployVirtualMachineParams(serviceofferingid string, templateid string, zoneid string) *DeployVirtualMachineParams { - p := &DeployVirtualMachineParams{} - p.p = make(map[string]interface{}) - p.p["serviceofferingid"] = serviceofferingid - p.p["templateid"] = templateid - p.p["zoneid"] = zoneid - return p -} - -// Creates and automatically starts a virtual machine based on a service offering, disk offering, and template. -func (s *VirtualMachineService) DeployVirtualMachine(p *DeployVirtualMachineParams) (*DeployVirtualMachineResponse, error) { - resp, err := s.cs.newRequest("deployVirtualMachine", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeployVirtualMachineResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DeployVirtualMachineResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Affinitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Type string `json:"type,omitempty"` - VirtualmachineIds []string `json:"virtualmachineIds,omitempty"` - } `json:"affinitygroup,omitempty"` - Cpunumber int `json:"cpunumber,omitempty"` - Cpuspeed int `json:"cpuspeed,omitempty"` - Cpuused string `json:"cpuused,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Diskioread int64 `json:"diskioread,omitempty"` - Diskiowrite int64 `json:"diskiowrite,omitempty"` - Diskkbsread int64 `json:"diskkbsread,omitempty"` - Diskkbswrite int64 `json:"diskkbswrite,omitempty"` - Diskofferingid string `json:"diskofferingid,omitempty"` - Diskofferingname string `json:"diskofferingname,omitempty"` - Displayname string `json:"displayname,omitempty"` - Displayvm bool `json:"displayvm,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"` - Group string `json:"group,omitempty"` - Groupid string `json:"groupid,omitempty"` - Guestosid string `json:"guestosid,omitempty"` - Haenable bool `json:"haenable,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Instancename string `json:"instancename,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isodisplaytext string `json:"isodisplaytext,omitempty"` - Isoid string `json:"isoid,omitempty"` - Isoname string `json:"isoname,omitempty"` - Keypair string `json:"keypair,omitempty"` - Memory int `json:"memory,omitempty"` - Name string `json:"name,omitempty"` - Networkkbsread int64 `json:"networkkbsread,omitempty"` - Networkkbswrite int64 `json:"networkkbswrite,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Ostypeid int64 `json:"ostypeid,omitempty"` - Password string `json:"password,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - Rootdeviceid int64 `json:"rootdeviceid,omitempty"` - Rootdevicetype string `json:"rootdevicetype,omitempty"` - Securitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Egressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"egressrule,omitempty"` - Id string `json:"id,omitempty"` - Ingressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"ingressrule,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinecount int `json:"virtualmachinecount,omitempty"` - Virtualmachineids []string `json:"virtualmachineids,omitempty"` - } `json:"securitygroup,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - Servicestate string `json:"servicestate,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatedisplaytext string `json:"templatedisplaytext,omitempty"` - Templateid string `json:"templateid,omitempty"` - Templatename string `json:"templatename,omitempty"` - Userid string `json:"userid,omitempty"` - Username string `json:"username,omitempty"` - Vgpu string `json:"vgpu,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type DestroyVirtualMachineParams struct { - p map[string]interface{} -} - -func (p *DestroyVirtualMachineParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["expunge"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("expunge", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DestroyVirtualMachineParams) SetExpunge(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["expunge"] = v - return -} - -func (p *DestroyVirtualMachineParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DestroyVirtualMachineParams instance, -// as then you are sure you have configured all required params -func (s *VirtualMachineService) NewDestroyVirtualMachineParams(id string) *DestroyVirtualMachineParams { - p := &DestroyVirtualMachineParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Destroys a virtual machine. -func (s *VirtualMachineService) DestroyVirtualMachine(p *DestroyVirtualMachineParams) (*DestroyVirtualMachineResponse, error) { - resp, err := s.cs.newRequest("destroyVirtualMachine", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DestroyVirtualMachineResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DestroyVirtualMachineResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Affinitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Type string `json:"type,omitempty"` - VirtualmachineIds []string `json:"virtualmachineIds,omitempty"` - } `json:"affinitygroup,omitempty"` - Cpunumber int `json:"cpunumber,omitempty"` - Cpuspeed int `json:"cpuspeed,omitempty"` - Cpuused string `json:"cpuused,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Diskioread int64 `json:"diskioread,omitempty"` - Diskiowrite int64 `json:"diskiowrite,omitempty"` - Diskkbsread int64 `json:"diskkbsread,omitempty"` - Diskkbswrite int64 `json:"diskkbswrite,omitempty"` - Diskofferingid string `json:"diskofferingid,omitempty"` - Diskofferingname string `json:"diskofferingname,omitempty"` - Displayname string `json:"displayname,omitempty"` - Displayvm bool `json:"displayvm,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"` - Group string `json:"group,omitempty"` - Groupid string `json:"groupid,omitempty"` - Guestosid string `json:"guestosid,omitempty"` - Haenable bool `json:"haenable,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Instancename string `json:"instancename,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isodisplaytext string `json:"isodisplaytext,omitempty"` - Isoid string `json:"isoid,omitempty"` - Isoname string `json:"isoname,omitempty"` - Keypair string `json:"keypair,omitempty"` - Memory int `json:"memory,omitempty"` - Name string `json:"name,omitempty"` - Networkkbsread int64 `json:"networkkbsread,omitempty"` - Networkkbswrite int64 `json:"networkkbswrite,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Ostypeid int64 `json:"ostypeid,omitempty"` - Password string `json:"password,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - Rootdeviceid int64 `json:"rootdeviceid,omitempty"` - Rootdevicetype string `json:"rootdevicetype,omitempty"` - Securitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Egressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"egressrule,omitempty"` - Id string `json:"id,omitempty"` - Ingressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"ingressrule,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinecount int `json:"virtualmachinecount,omitempty"` - Virtualmachineids []string `json:"virtualmachineids,omitempty"` - } `json:"securitygroup,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - Servicestate string `json:"servicestate,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatedisplaytext string `json:"templatedisplaytext,omitempty"` - Templateid string `json:"templateid,omitempty"` - Templatename string `json:"templatename,omitempty"` - Userid string `json:"userid,omitempty"` - Username string `json:"username,omitempty"` - Vgpu string `json:"vgpu,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type RebootVirtualMachineParams struct { - p map[string]interface{} -} - -func (p *RebootVirtualMachineParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *RebootVirtualMachineParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new RebootVirtualMachineParams instance, -// as then you are sure you have configured all required params -func (s *VirtualMachineService) NewRebootVirtualMachineParams(id string) *RebootVirtualMachineParams { - p := &RebootVirtualMachineParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Reboots a virtual machine. -func (s *VirtualMachineService) RebootVirtualMachine(p *RebootVirtualMachineParams) (*RebootVirtualMachineResponse, error) { - resp, err := s.cs.newRequest("rebootVirtualMachine", p.toURLValues()) - if err != nil { - return nil, err - } - - var r RebootVirtualMachineResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type RebootVirtualMachineResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Affinitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Type string `json:"type,omitempty"` - VirtualmachineIds []string `json:"virtualmachineIds,omitempty"` - } `json:"affinitygroup,omitempty"` - Cpunumber int `json:"cpunumber,omitempty"` - Cpuspeed int `json:"cpuspeed,omitempty"` - Cpuused string `json:"cpuused,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Diskioread int64 `json:"diskioread,omitempty"` - Diskiowrite int64 `json:"diskiowrite,omitempty"` - Diskkbsread int64 `json:"diskkbsread,omitempty"` - Diskkbswrite int64 `json:"diskkbswrite,omitempty"` - Diskofferingid string `json:"diskofferingid,omitempty"` - Diskofferingname string `json:"diskofferingname,omitempty"` - Displayname string `json:"displayname,omitempty"` - Displayvm bool `json:"displayvm,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"` - Group string `json:"group,omitempty"` - Groupid string `json:"groupid,omitempty"` - Guestosid string `json:"guestosid,omitempty"` - Haenable bool `json:"haenable,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Instancename string `json:"instancename,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isodisplaytext string `json:"isodisplaytext,omitempty"` - Isoid string `json:"isoid,omitempty"` - Isoname string `json:"isoname,omitempty"` - Keypair string `json:"keypair,omitempty"` - Memory int `json:"memory,omitempty"` - Name string `json:"name,omitempty"` - Networkkbsread int64 `json:"networkkbsread,omitempty"` - Networkkbswrite int64 `json:"networkkbswrite,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Ostypeid int64 `json:"ostypeid,omitempty"` - Password string `json:"password,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - Rootdeviceid int64 `json:"rootdeviceid,omitempty"` - Rootdevicetype string `json:"rootdevicetype,omitempty"` - Securitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Egressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"egressrule,omitempty"` - Id string `json:"id,omitempty"` - Ingressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"ingressrule,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinecount int `json:"virtualmachinecount,omitempty"` - Virtualmachineids []string `json:"virtualmachineids,omitempty"` - } `json:"securitygroup,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - Servicestate string `json:"servicestate,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatedisplaytext string `json:"templatedisplaytext,omitempty"` - Templateid string `json:"templateid,omitempty"` - Templatename string `json:"templatename,omitempty"` - Userid string `json:"userid,omitempty"` - Username string `json:"username,omitempty"` - Vgpu string `json:"vgpu,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type StartVirtualMachineParams struct { - p map[string]interface{} -} - -func (p *StartVirtualMachineParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["deploymentplanner"]; found { - u.Set("deploymentplanner", v.(string)) - } - if v, found := p.p["hostid"]; found { - u.Set("hostid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *StartVirtualMachineParams) SetDeploymentplanner(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["deploymentplanner"] = v - return -} - -func (p *StartVirtualMachineParams) SetHostid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hostid"] = v - return -} - -func (p *StartVirtualMachineParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new StartVirtualMachineParams instance, -// as then you are sure you have configured all required params -func (s *VirtualMachineService) NewStartVirtualMachineParams(id string) *StartVirtualMachineParams { - p := &StartVirtualMachineParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Starts a virtual machine. -func (s *VirtualMachineService) StartVirtualMachine(p *StartVirtualMachineParams) (*StartVirtualMachineResponse, error) { - resp, err := s.cs.newRequest("startVirtualMachine", p.toURLValues()) - if err != nil { - return nil, err - } - - var r StartVirtualMachineResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type StartVirtualMachineResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Affinitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Type string `json:"type,omitempty"` - VirtualmachineIds []string `json:"virtualmachineIds,omitempty"` - } `json:"affinitygroup,omitempty"` - Cpunumber int `json:"cpunumber,omitempty"` - Cpuspeed int `json:"cpuspeed,omitempty"` - Cpuused string `json:"cpuused,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Diskioread int64 `json:"diskioread,omitempty"` - Diskiowrite int64 `json:"diskiowrite,omitempty"` - Diskkbsread int64 `json:"diskkbsread,omitempty"` - Diskkbswrite int64 `json:"diskkbswrite,omitempty"` - Diskofferingid string `json:"diskofferingid,omitempty"` - Diskofferingname string `json:"diskofferingname,omitempty"` - Displayname string `json:"displayname,omitempty"` - Displayvm bool `json:"displayvm,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"` - Group string `json:"group,omitempty"` - Groupid string `json:"groupid,omitempty"` - Guestosid string `json:"guestosid,omitempty"` - Haenable bool `json:"haenable,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Instancename string `json:"instancename,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isodisplaytext string `json:"isodisplaytext,omitempty"` - Isoid string `json:"isoid,omitempty"` - Isoname string `json:"isoname,omitempty"` - Keypair string `json:"keypair,omitempty"` - Memory int `json:"memory,omitempty"` - Name string `json:"name,omitempty"` - Networkkbsread int64 `json:"networkkbsread,omitempty"` - Networkkbswrite int64 `json:"networkkbswrite,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Ostypeid int64 `json:"ostypeid,omitempty"` - Password string `json:"password,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - Rootdeviceid int64 `json:"rootdeviceid,omitempty"` - Rootdevicetype string `json:"rootdevicetype,omitempty"` - Securitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Egressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"egressrule,omitempty"` - Id string `json:"id,omitempty"` - Ingressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"ingressrule,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinecount int `json:"virtualmachinecount,omitempty"` - Virtualmachineids []string `json:"virtualmachineids,omitempty"` - } `json:"securitygroup,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - Servicestate string `json:"servicestate,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatedisplaytext string `json:"templatedisplaytext,omitempty"` - Templateid string `json:"templateid,omitempty"` - Templatename string `json:"templatename,omitempty"` - Userid string `json:"userid,omitempty"` - Username string `json:"username,omitempty"` - Vgpu string `json:"vgpu,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type StopVirtualMachineParams struct { - p map[string]interface{} -} - -func (p *StopVirtualMachineParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["forced"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("forced", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *StopVirtualMachineParams) SetForced(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["forced"] = v - return -} - -func (p *StopVirtualMachineParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new StopVirtualMachineParams instance, -// as then you are sure you have configured all required params -func (s *VirtualMachineService) NewStopVirtualMachineParams(id string) *StopVirtualMachineParams { - p := &StopVirtualMachineParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Stops a virtual machine. -func (s *VirtualMachineService) StopVirtualMachine(p *StopVirtualMachineParams) (*StopVirtualMachineResponse, error) { - resp, err := s.cs.newRequest("stopVirtualMachine", p.toURLValues()) - if err != nil { - return nil, err - } - - var r StopVirtualMachineResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type StopVirtualMachineResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Affinitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Type string `json:"type,omitempty"` - VirtualmachineIds []string `json:"virtualmachineIds,omitempty"` - } `json:"affinitygroup,omitempty"` - Cpunumber int `json:"cpunumber,omitempty"` - Cpuspeed int `json:"cpuspeed,omitempty"` - Cpuused string `json:"cpuused,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Diskioread int64 `json:"diskioread,omitempty"` - Diskiowrite int64 `json:"diskiowrite,omitempty"` - Diskkbsread int64 `json:"diskkbsread,omitempty"` - Diskkbswrite int64 `json:"diskkbswrite,omitempty"` - Diskofferingid string `json:"diskofferingid,omitempty"` - Diskofferingname string `json:"diskofferingname,omitempty"` - Displayname string `json:"displayname,omitempty"` - Displayvm bool `json:"displayvm,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"` - Group string `json:"group,omitempty"` - Groupid string `json:"groupid,omitempty"` - Guestosid string `json:"guestosid,omitempty"` - Haenable bool `json:"haenable,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Instancename string `json:"instancename,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isodisplaytext string `json:"isodisplaytext,omitempty"` - Isoid string `json:"isoid,omitempty"` - Isoname string `json:"isoname,omitempty"` - Keypair string `json:"keypair,omitempty"` - Memory int `json:"memory,omitempty"` - Name string `json:"name,omitempty"` - Networkkbsread int64 `json:"networkkbsread,omitempty"` - Networkkbswrite int64 `json:"networkkbswrite,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Ostypeid int64 `json:"ostypeid,omitempty"` - Password string `json:"password,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - Rootdeviceid int64 `json:"rootdeviceid,omitempty"` - Rootdevicetype string `json:"rootdevicetype,omitempty"` - Securitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Egressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"egressrule,omitempty"` - Id string `json:"id,omitempty"` - Ingressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"ingressrule,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinecount int `json:"virtualmachinecount,omitempty"` - Virtualmachineids []string `json:"virtualmachineids,omitempty"` - } `json:"securitygroup,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - Servicestate string `json:"servicestate,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatedisplaytext string `json:"templatedisplaytext,omitempty"` - Templateid string `json:"templateid,omitempty"` - Templatename string `json:"templatename,omitempty"` - Userid string `json:"userid,omitempty"` - Username string `json:"username,omitempty"` - Vgpu string `json:"vgpu,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type ResetPasswordForVirtualMachineParams struct { - p map[string]interface{} -} - -func (p *ResetPasswordForVirtualMachineParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *ResetPasswordForVirtualMachineParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new ResetPasswordForVirtualMachineParams instance, -// as then you are sure you have configured all required params -func (s *VirtualMachineService) NewResetPasswordForVirtualMachineParams(id string) *ResetPasswordForVirtualMachineParams { - p := &ResetPasswordForVirtualMachineParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Resets the password for virtual machine. The virtual machine must be in a "Stopped" state and the template must already support this feature for this command to take effect. [async] -func (s *VirtualMachineService) ResetPasswordForVirtualMachine(p *ResetPasswordForVirtualMachineParams) (*ResetPasswordForVirtualMachineResponse, error) { - resp, err := s.cs.newRequest("resetPasswordForVirtualMachine", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ResetPasswordForVirtualMachineResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type ResetPasswordForVirtualMachineResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Affinitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Type string `json:"type,omitempty"` - VirtualmachineIds []string `json:"virtualmachineIds,omitempty"` - } `json:"affinitygroup,omitempty"` - Cpunumber int `json:"cpunumber,omitempty"` - Cpuspeed int `json:"cpuspeed,omitempty"` - Cpuused string `json:"cpuused,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Diskioread int64 `json:"diskioread,omitempty"` - Diskiowrite int64 `json:"diskiowrite,omitempty"` - Diskkbsread int64 `json:"diskkbsread,omitempty"` - Diskkbswrite int64 `json:"diskkbswrite,omitempty"` - Diskofferingid string `json:"diskofferingid,omitempty"` - Diskofferingname string `json:"diskofferingname,omitempty"` - Displayname string `json:"displayname,omitempty"` - Displayvm bool `json:"displayvm,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"` - Group string `json:"group,omitempty"` - Groupid string `json:"groupid,omitempty"` - Guestosid string `json:"guestosid,omitempty"` - Haenable bool `json:"haenable,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Instancename string `json:"instancename,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isodisplaytext string `json:"isodisplaytext,omitempty"` - Isoid string `json:"isoid,omitempty"` - Isoname string `json:"isoname,omitempty"` - Keypair string `json:"keypair,omitempty"` - Memory int `json:"memory,omitempty"` - Name string `json:"name,omitempty"` - Networkkbsread int64 `json:"networkkbsread,omitempty"` - Networkkbswrite int64 `json:"networkkbswrite,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Ostypeid int64 `json:"ostypeid,omitempty"` - Password string `json:"password,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - Rootdeviceid int64 `json:"rootdeviceid,omitempty"` - Rootdevicetype string `json:"rootdevicetype,omitempty"` - Securitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Egressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"egressrule,omitempty"` - Id string `json:"id,omitempty"` - Ingressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"ingressrule,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinecount int `json:"virtualmachinecount,omitempty"` - Virtualmachineids []string `json:"virtualmachineids,omitempty"` - } `json:"securitygroup,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - Servicestate string `json:"servicestate,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatedisplaytext string `json:"templatedisplaytext,omitempty"` - Templateid string `json:"templateid,omitempty"` - Templatename string `json:"templatename,omitempty"` - Userid string `json:"userid,omitempty"` - Username string `json:"username,omitempty"` - Vgpu string `json:"vgpu,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type UpdateVirtualMachineParams struct { - p map[string]interface{} -} - -func (p *UpdateVirtualMachineParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["customid"]; found { - u.Set("customid", v.(string)) - } - if v, found := p.p["details"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("details[%d].key", i), k) - u.Set(fmt.Sprintf("details[%d].value", i), vv) - i++ - } - } - if v, found := p.p["displayname"]; found { - u.Set("displayname", v.(string)) - } - if v, found := p.p["displayvm"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("displayvm", vv) - } - if v, found := p.p["group"]; found { - u.Set("group", v.(string)) - } - if v, found := p.p["haenable"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("haenable", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["instancename"]; found { - u.Set("instancename", v.(string)) - } - if v, found := p.p["isdynamicallyscalable"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isdynamicallyscalable", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["ostypeid"]; found { - u.Set("ostypeid", v.(string)) - } - if v, found := p.p["userdata"]; found { - u.Set("userdata", v.(string)) - } - return u -} - -func (p *UpdateVirtualMachineParams) SetCustomid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["customid"] = v - return -} - -func (p *UpdateVirtualMachineParams) SetDetails(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["details"] = v - return -} - -func (p *UpdateVirtualMachineParams) SetDisplayname(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displayname"] = v - return -} - -func (p *UpdateVirtualMachineParams) SetDisplayvm(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displayvm"] = v - return -} - -func (p *UpdateVirtualMachineParams) SetGroup(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["group"] = v - return -} - -func (p *UpdateVirtualMachineParams) SetHaenable(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["haenable"] = v - return -} - -func (p *UpdateVirtualMachineParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateVirtualMachineParams) SetInstancename(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["instancename"] = v - return -} - -func (p *UpdateVirtualMachineParams) SetIsdynamicallyscalable(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isdynamicallyscalable"] = v - return -} - -func (p *UpdateVirtualMachineParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *UpdateVirtualMachineParams) SetOstypeid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ostypeid"] = v - return -} - -func (p *UpdateVirtualMachineParams) SetUserdata(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["userdata"] = v - return -} - -// You should always use this function to get a new UpdateVirtualMachineParams instance, -// as then you are sure you have configured all required params -func (s *VirtualMachineService) NewUpdateVirtualMachineParams(id string) *UpdateVirtualMachineParams { - p := &UpdateVirtualMachineParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates properties of a virtual machine. The VM has to be stopped and restarted for the new properties to take effect. UpdateVirtualMachine does not first check whether the VM is stopped. Therefore, stop the VM manually before issuing this call. -func (s *VirtualMachineService) UpdateVirtualMachine(p *UpdateVirtualMachineParams) (*UpdateVirtualMachineResponse, error) { - resp, err := s.cs.newRequest("updateVirtualMachine", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateVirtualMachineResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type UpdateVirtualMachineResponse struct { - Account string `json:"account,omitempty"` - Affinitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Type string `json:"type,omitempty"` - VirtualmachineIds []string `json:"virtualmachineIds,omitempty"` - } `json:"affinitygroup,omitempty"` - Cpunumber int `json:"cpunumber,omitempty"` - Cpuspeed int `json:"cpuspeed,omitempty"` - Cpuused string `json:"cpuused,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Diskioread int64 `json:"diskioread,omitempty"` - Diskiowrite int64 `json:"diskiowrite,omitempty"` - Diskkbsread int64 `json:"diskkbsread,omitempty"` - Diskkbswrite int64 `json:"diskkbswrite,omitempty"` - Diskofferingid string `json:"diskofferingid,omitempty"` - Diskofferingname string `json:"diskofferingname,omitempty"` - Displayname string `json:"displayname,omitempty"` - Displayvm bool `json:"displayvm,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"` - Group string `json:"group,omitempty"` - Groupid string `json:"groupid,omitempty"` - Guestosid string `json:"guestosid,omitempty"` - Haenable bool `json:"haenable,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Instancename string `json:"instancename,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isodisplaytext string `json:"isodisplaytext,omitempty"` - Isoid string `json:"isoid,omitempty"` - Isoname string `json:"isoname,omitempty"` - Keypair string `json:"keypair,omitempty"` - Memory int `json:"memory,omitempty"` - Name string `json:"name,omitempty"` - Networkkbsread int64 `json:"networkkbsread,omitempty"` - Networkkbswrite int64 `json:"networkkbswrite,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Ostypeid int64 `json:"ostypeid,omitempty"` - Password string `json:"password,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - Rootdeviceid int64 `json:"rootdeviceid,omitempty"` - Rootdevicetype string `json:"rootdevicetype,omitempty"` - Securitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Egressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"egressrule,omitempty"` - Id string `json:"id,omitempty"` - Ingressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"ingressrule,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinecount int `json:"virtualmachinecount,omitempty"` - Virtualmachineids []string `json:"virtualmachineids,omitempty"` - } `json:"securitygroup,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - Servicestate string `json:"servicestate,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatedisplaytext string `json:"templatedisplaytext,omitempty"` - Templateid string `json:"templateid,omitempty"` - Templatename string `json:"templatename,omitempty"` - Userid string `json:"userid,omitempty"` - Username string `json:"username,omitempty"` - Vgpu string `json:"vgpu,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type ListVirtualMachinesParams struct { - p map[string]interface{} -} - -func (p *ListVirtualMachinesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["affinitygroupid"]; found { - u.Set("affinitygroupid", v.(string)) - } - if v, found := p.p["details"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("details", vv) - } - if v, found := p.p["displayvm"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("displayvm", vv) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["forvirtualnetwork"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("forvirtualnetwork", vv) - } - if v, found := p.p["groupid"]; found { - u.Set("groupid", v.(string)) - } - if v, found := p.p["hostid"]; found { - u.Set("hostid", v.(string)) - } - if v, found := p.p["hostid"]; found { - u.Set("hostid", v.(string)) - } - if v, found := p.p["hypervisor"]; found { - u.Set("hypervisor", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["ids"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("ids", vv) - } - if v, found := p.p["isoid"]; found { - u.Set("isoid", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keypair"]; found { - u.Set("keypair", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["networkid"]; found { - u.Set("networkid", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["podid"]; found { - u.Set("podid", v.(string)) - } - if v, found := p.p["podid"]; found { - u.Set("podid", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["serviceofferingid"]; found { - u.Set("serviceofferingid", v.(string)) - } - if v, found := p.p["state"]; found { - u.Set("state", v.(string)) - } - if v, found := p.p["storageid"]; found { - u.Set("storageid", v.(string)) - } - if v, found := p.p["storageid"]; found { - u.Set("storageid", v.(string)) - } - if v, found := p.p["tags"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("tags[%d].key", i), k) - u.Set(fmt.Sprintf("tags[%d].value", i), vv) - i++ - } - } - if v, found := p.p["templateid"]; found { - u.Set("templateid", v.(string)) - } - if v, found := p.p["userid"]; found { - u.Set("userid", v.(string)) - } - if v, found := p.p["vpcid"]; found { - u.Set("vpcid", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ListVirtualMachinesParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListVirtualMachinesParams) SetAffinitygroupid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["affinitygroupid"] = v - return -} - -func (p *ListVirtualMachinesParams) SetDetails(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["details"] = v - return -} - -func (p *ListVirtualMachinesParams) SetDisplayvm(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displayvm"] = v - return -} - -func (p *ListVirtualMachinesParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListVirtualMachinesParams) SetForvirtualnetwork(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["forvirtualnetwork"] = v - return -} - -func (p *ListVirtualMachinesParams) SetGroupid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["groupid"] = v - return -} - -func (p *ListVirtualMachinesParams) SetHostid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hostid"] = v - return -} - -func (p *ListVirtualMachinesParams) SetHypervisor(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hypervisor"] = v - return -} - -func (p *ListVirtualMachinesParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListVirtualMachinesParams) SetIds(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ids"] = v - return -} - -func (p *ListVirtualMachinesParams) SetIsoid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isoid"] = v - return -} - -func (p *ListVirtualMachinesParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListVirtualMachinesParams) SetKeypair(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keypair"] = v - return -} - -func (p *ListVirtualMachinesParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListVirtualMachinesParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListVirtualMachinesParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListVirtualMachinesParams) SetNetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkid"] = v - return -} - -func (p *ListVirtualMachinesParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListVirtualMachinesParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListVirtualMachinesParams) SetPodid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["podid"] = v - return -} - -func (p *ListVirtualMachinesParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListVirtualMachinesParams) SetServiceofferingid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["serviceofferingid"] = v - return -} - -func (p *ListVirtualMachinesParams) SetState(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["state"] = v - return -} - -func (p *ListVirtualMachinesParams) SetStorageid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["storageid"] = v - return -} - -func (p *ListVirtualMachinesParams) SetTags(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tags"] = v - return -} - -func (p *ListVirtualMachinesParams) SetTemplateid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["templateid"] = v - return -} - -func (p *ListVirtualMachinesParams) SetUserid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["userid"] = v - return -} - -func (p *ListVirtualMachinesParams) SetVpcid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["vpcid"] = v - return -} - -func (p *ListVirtualMachinesParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ListVirtualMachinesParams instance, -// as then you are sure you have configured all required params -func (s *VirtualMachineService) NewListVirtualMachinesParams() *ListVirtualMachinesParams { - p := &ListVirtualMachinesParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *VirtualMachineService) GetVirtualMachineID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListVirtualMachinesParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListVirtualMachines(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.VirtualMachines[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.VirtualMachines { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *VirtualMachineService) GetVirtualMachineByName(name string, opts ...OptionFunc) (*VirtualMachine, int, error) { - id, count, err := s.GetVirtualMachineID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetVirtualMachineByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *VirtualMachineService) GetVirtualMachineByID(id string, opts ...OptionFunc) (*VirtualMachine, int, error) { - p := &ListVirtualMachinesParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListVirtualMachines(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.VirtualMachines[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for VirtualMachine UUID: %s!", id) -} - -// List the virtual machines owned by the account. -func (s *VirtualMachineService) ListVirtualMachines(p *ListVirtualMachinesParams) (*ListVirtualMachinesResponse, error) { - resp, err := s.cs.newRequest("listVirtualMachines", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListVirtualMachinesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListVirtualMachinesResponse struct { - Count int `json:"count"` - VirtualMachines []*VirtualMachine `json:"virtualmachine"` -} - -type VirtualMachine struct { - Account string `json:"account,omitempty"` - Affinitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Type string `json:"type,omitempty"` - VirtualmachineIds []string `json:"virtualmachineIds,omitempty"` - } `json:"affinitygroup,omitempty"` - Cpunumber int `json:"cpunumber,omitempty"` - Cpuspeed int `json:"cpuspeed,omitempty"` - Cpuused string `json:"cpuused,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Diskioread int64 `json:"diskioread,omitempty"` - Diskiowrite int64 `json:"diskiowrite,omitempty"` - Diskkbsread int64 `json:"diskkbsread,omitempty"` - Diskkbswrite int64 `json:"diskkbswrite,omitempty"` - Diskofferingid string `json:"diskofferingid,omitempty"` - Diskofferingname string `json:"diskofferingname,omitempty"` - Displayname string `json:"displayname,omitempty"` - Displayvm bool `json:"displayvm,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"` - Group string `json:"group,omitempty"` - Groupid string `json:"groupid,omitempty"` - Guestosid string `json:"guestosid,omitempty"` - Haenable bool `json:"haenable,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Instancename string `json:"instancename,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isodisplaytext string `json:"isodisplaytext,omitempty"` - Isoid string `json:"isoid,omitempty"` - Isoname string `json:"isoname,omitempty"` - Keypair string `json:"keypair,omitempty"` - Memory int `json:"memory,omitempty"` - Name string `json:"name,omitempty"` - Networkkbsread int64 `json:"networkkbsread,omitempty"` - Networkkbswrite int64 `json:"networkkbswrite,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Ostypeid int64 `json:"ostypeid,omitempty"` - Password string `json:"password,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - Rootdeviceid int64 `json:"rootdeviceid,omitempty"` - Rootdevicetype string `json:"rootdevicetype,omitempty"` - Securitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Egressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"egressrule,omitempty"` - Id string `json:"id,omitempty"` - Ingressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"ingressrule,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinecount int `json:"virtualmachinecount,omitempty"` - Virtualmachineids []string `json:"virtualmachineids,omitempty"` - } `json:"securitygroup,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - Servicestate string `json:"servicestate,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatedisplaytext string `json:"templatedisplaytext,omitempty"` - Templateid string `json:"templateid,omitempty"` - Templatename string `json:"templatename,omitempty"` - Userid string `json:"userid,omitempty"` - Username string `json:"username,omitempty"` - Vgpu string `json:"vgpu,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type GetVMPasswordParams struct { - p map[string]interface{} -} - -func (p *GetVMPasswordParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *GetVMPasswordParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new GetVMPasswordParams instance, -// as then you are sure you have configured all required params -func (s *VirtualMachineService) NewGetVMPasswordParams(id string) *GetVMPasswordParams { - p := &GetVMPasswordParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Returns an encrypted password for the VM -func (s *VirtualMachineService) GetVMPassword(p *GetVMPasswordParams) (*GetVMPasswordResponse, error) { - resp, err := s.cs.newRequest("getVMPassword", p.toURLValues()) - if err != nil { - return nil, err - } - - var r GetVMPasswordResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type GetVMPasswordResponse struct { - Encryptedpassword string `json:"encryptedpassword,omitempty"` -} - -type RestoreVirtualMachineParams struct { - p map[string]interface{} -} - -func (p *RestoreVirtualMachineParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["templateid"]; found { - u.Set("templateid", v.(string)) - } - if v, found := p.p["virtualmachineid"]; found { - u.Set("virtualmachineid", v.(string)) - } - return u -} - -func (p *RestoreVirtualMachineParams) SetTemplateid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["templateid"] = v - return -} - -func (p *RestoreVirtualMachineParams) SetVirtualmachineid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["virtualmachineid"] = v - return -} - -// You should always use this function to get a new RestoreVirtualMachineParams instance, -// as then you are sure you have configured all required params -func (s *VirtualMachineService) NewRestoreVirtualMachineParams(virtualmachineid string) *RestoreVirtualMachineParams { - p := &RestoreVirtualMachineParams{} - p.p = make(map[string]interface{}) - p.p["virtualmachineid"] = virtualmachineid - return p -} - -// Restore a VM to original template/ISO or new template/ISO -func (s *VirtualMachineService) RestoreVirtualMachine(p *RestoreVirtualMachineParams) (*RestoreVirtualMachineResponse, error) { - resp, err := s.cs.newRequest("restoreVirtualMachine", p.toURLValues()) - if err != nil { - return nil, err - } - - var r RestoreVirtualMachineResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type RestoreVirtualMachineResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Affinitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Type string `json:"type,omitempty"` - VirtualmachineIds []string `json:"virtualmachineIds,omitempty"` - } `json:"affinitygroup,omitempty"` - Cpunumber int `json:"cpunumber,omitempty"` - Cpuspeed int `json:"cpuspeed,omitempty"` - Cpuused string `json:"cpuused,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Diskioread int64 `json:"diskioread,omitempty"` - Diskiowrite int64 `json:"diskiowrite,omitempty"` - Diskkbsread int64 `json:"diskkbsread,omitempty"` - Diskkbswrite int64 `json:"diskkbswrite,omitempty"` - Diskofferingid string `json:"diskofferingid,omitempty"` - Diskofferingname string `json:"diskofferingname,omitempty"` - Displayname string `json:"displayname,omitempty"` - Displayvm bool `json:"displayvm,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"` - Group string `json:"group,omitempty"` - Groupid string `json:"groupid,omitempty"` - Guestosid string `json:"guestosid,omitempty"` - Haenable bool `json:"haenable,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Instancename string `json:"instancename,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isodisplaytext string `json:"isodisplaytext,omitempty"` - Isoid string `json:"isoid,omitempty"` - Isoname string `json:"isoname,omitempty"` - Keypair string `json:"keypair,omitempty"` - Memory int `json:"memory,omitempty"` - Name string `json:"name,omitempty"` - Networkkbsread int64 `json:"networkkbsread,omitempty"` - Networkkbswrite int64 `json:"networkkbswrite,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Ostypeid int64 `json:"ostypeid,omitempty"` - Password string `json:"password,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - Rootdeviceid int64 `json:"rootdeviceid,omitempty"` - Rootdevicetype string `json:"rootdevicetype,omitempty"` - Securitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Egressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"egressrule,omitempty"` - Id string `json:"id,omitempty"` - Ingressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"ingressrule,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinecount int `json:"virtualmachinecount,omitempty"` - Virtualmachineids []string `json:"virtualmachineids,omitempty"` - } `json:"securitygroup,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - Servicestate string `json:"servicestate,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatedisplaytext string `json:"templatedisplaytext,omitempty"` - Templateid string `json:"templateid,omitempty"` - Templatename string `json:"templatename,omitempty"` - Userid string `json:"userid,omitempty"` - Username string `json:"username,omitempty"` - Vgpu string `json:"vgpu,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type ChangeServiceForVirtualMachineParams struct { - p map[string]interface{} -} - -func (p *ChangeServiceForVirtualMachineParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["details"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("details[%d].key", i), k) - u.Set(fmt.Sprintf("details[%d].value", i), vv) - i++ - } - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["serviceofferingid"]; found { - u.Set("serviceofferingid", v.(string)) - } - return u -} - -func (p *ChangeServiceForVirtualMachineParams) SetDetails(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["details"] = v - return -} - -func (p *ChangeServiceForVirtualMachineParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ChangeServiceForVirtualMachineParams) SetServiceofferingid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["serviceofferingid"] = v - return -} - -// You should always use this function to get a new ChangeServiceForVirtualMachineParams instance, -// as then you are sure you have configured all required params -func (s *VirtualMachineService) NewChangeServiceForVirtualMachineParams(id string, serviceofferingid string) *ChangeServiceForVirtualMachineParams { - p := &ChangeServiceForVirtualMachineParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - p.p["serviceofferingid"] = serviceofferingid - return p -} - -// Changes the service offering for a virtual machine. The virtual machine must be in a "Stopped" state for this command to take effect. -func (s *VirtualMachineService) ChangeServiceForVirtualMachine(p *ChangeServiceForVirtualMachineParams) (*ChangeServiceForVirtualMachineResponse, error) { - resp, err := s.cs.newRequest("changeServiceForVirtualMachine", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ChangeServiceForVirtualMachineResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ChangeServiceForVirtualMachineResponse struct { - Account string `json:"account,omitempty"` - Affinitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Type string `json:"type,omitempty"` - VirtualmachineIds []string `json:"virtualmachineIds,omitempty"` - } `json:"affinitygroup,omitempty"` - Cpunumber int `json:"cpunumber,omitempty"` - Cpuspeed int `json:"cpuspeed,omitempty"` - Cpuused string `json:"cpuused,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Diskioread int64 `json:"diskioread,omitempty"` - Diskiowrite int64 `json:"diskiowrite,omitempty"` - Diskkbsread int64 `json:"diskkbsread,omitempty"` - Diskkbswrite int64 `json:"diskkbswrite,omitempty"` - Diskofferingid string `json:"diskofferingid,omitempty"` - Diskofferingname string `json:"diskofferingname,omitempty"` - Displayname string `json:"displayname,omitempty"` - Displayvm bool `json:"displayvm,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"` - Group string `json:"group,omitempty"` - Groupid string `json:"groupid,omitempty"` - Guestosid string `json:"guestosid,omitempty"` - Haenable bool `json:"haenable,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Instancename string `json:"instancename,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isodisplaytext string `json:"isodisplaytext,omitempty"` - Isoid string `json:"isoid,omitempty"` - Isoname string `json:"isoname,omitempty"` - Keypair string `json:"keypair,omitempty"` - Memory int `json:"memory,omitempty"` - Name string `json:"name,omitempty"` - Networkkbsread int64 `json:"networkkbsread,omitempty"` - Networkkbswrite int64 `json:"networkkbswrite,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Ostypeid int64 `json:"ostypeid,omitempty"` - Password string `json:"password,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - Rootdeviceid int64 `json:"rootdeviceid,omitempty"` - Rootdevicetype string `json:"rootdevicetype,omitempty"` - Securitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Egressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"egressrule,omitempty"` - Id string `json:"id,omitempty"` - Ingressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"ingressrule,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinecount int `json:"virtualmachinecount,omitempty"` - Virtualmachineids []string `json:"virtualmachineids,omitempty"` - } `json:"securitygroup,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - Servicestate string `json:"servicestate,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatedisplaytext string `json:"templatedisplaytext,omitempty"` - Templateid string `json:"templateid,omitempty"` - Templatename string `json:"templatename,omitempty"` - Userid string `json:"userid,omitempty"` - Username string `json:"username,omitempty"` - Vgpu string `json:"vgpu,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type ScaleVirtualMachineParams struct { - p map[string]interface{} -} - -func (p *ScaleVirtualMachineParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["details"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("details[%d].key", i), k) - u.Set(fmt.Sprintf("details[%d].value", i), vv) - i++ - } - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["serviceofferingid"]; found { - u.Set("serviceofferingid", v.(string)) - } - return u -} - -func (p *ScaleVirtualMachineParams) SetDetails(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["details"] = v - return -} - -func (p *ScaleVirtualMachineParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ScaleVirtualMachineParams) SetServiceofferingid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["serviceofferingid"] = v - return -} - -// You should always use this function to get a new ScaleVirtualMachineParams instance, -// as then you are sure you have configured all required params -func (s *VirtualMachineService) NewScaleVirtualMachineParams(id string, serviceofferingid string) *ScaleVirtualMachineParams { - p := &ScaleVirtualMachineParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - p.p["serviceofferingid"] = serviceofferingid - return p -} - -// Scales the virtual machine to a new service offering. -func (s *VirtualMachineService) ScaleVirtualMachine(p *ScaleVirtualMachineParams) (*ScaleVirtualMachineResponse, error) { - resp, err := s.cs.newRequest("scaleVirtualMachine", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ScaleVirtualMachineResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type ScaleVirtualMachineResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type AssignVirtualMachineParams struct { - p map[string]interface{} -} - -func (p *AssignVirtualMachineParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["networkids"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("networkids", vv) - } - if v, found := p.p["securitygroupids"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("securitygroupids", vv) - } - if v, found := p.p["virtualmachineid"]; found { - u.Set("virtualmachineid", v.(string)) - } - return u -} - -func (p *AssignVirtualMachineParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *AssignVirtualMachineParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *AssignVirtualMachineParams) SetNetworkids(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkids"] = v - return -} - -func (p *AssignVirtualMachineParams) SetSecuritygroupids(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["securitygroupids"] = v - return -} - -func (p *AssignVirtualMachineParams) SetVirtualmachineid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["virtualmachineid"] = v - return -} - -// You should always use this function to get a new AssignVirtualMachineParams instance, -// as then you are sure you have configured all required params -func (s *VirtualMachineService) NewAssignVirtualMachineParams(account string, domainid string, virtualmachineid string) *AssignVirtualMachineParams { - p := &AssignVirtualMachineParams{} - p.p = make(map[string]interface{}) - p.p["account"] = account - p.p["domainid"] = domainid - p.p["virtualmachineid"] = virtualmachineid - return p -} - -// Change ownership of a VM from one account to another. This API is available for Basic zones with security groups and Advanced zones with guest networks. A root administrator can reassign a VM from any account to any other account in any domain. A domain administrator can reassign a VM to any account in the same domain. -func (s *VirtualMachineService) AssignVirtualMachine(p *AssignVirtualMachineParams) (*AssignVirtualMachineResponse, error) { - resp, err := s.cs.newRequest("assignVirtualMachine", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AssignVirtualMachineResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type AssignVirtualMachineResponse struct { - Account string `json:"account,omitempty"` - Affinitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Type string `json:"type,omitempty"` - VirtualmachineIds []string `json:"virtualmachineIds,omitempty"` - } `json:"affinitygroup,omitempty"` - Cpunumber int `json:"cpunumber,omitempty"` - Cpuspeed int `json:"cpuspeed,omitempty"` - Cpuused string `json:"cpuused,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Diskioread int64 `json:"diskioread,omitempty"` - Diskiowrite int64 `json:"diskiowrite,omitempty"` - Diskkbsread int64 `json:"diskkbsread,omitempty"` - Diskkbswrite int64 `json:"diskkbswrite,omitempty"` - Diskofferingid string `json:"diskofferingid,omitempty"` - Diskofferingname string `json:"diskofferingname,omitempty"` - Displayname string `json:"displayname,omitempty"` - Displayvm bool `json:"displayvm,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"` - Group string `json:"group,omitempty"` - Groupid string `json:"groupid,omitempty"` - Guestosid string `json:"guestosid,omitempty"` - Haenable bool `json:"haenable,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Instancename string `json:"instancename,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isodisplaytext string `json:"isodisplaytext,omitempty"` - Isoid string `json:"isoid,omitempty"` - Isoname string `json:"isoname,omitempty"` - Keypair string `json:"keypair,omitempty"` - Memory int `json:"memory,omitempty"` - Name string `json:"name,omitempty"` - Networkkbsread int64 `json:"networkkbsread,omitempty"` - Networkkbswrite int64 `json:"networkkbswrite,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Ostypeid int64 `json:"ostypeid,omitempty"` - Password string `json:"password,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - Rootdeviceid int64 `json:"rootdeviceid,omitempty"` - Rootdevicetype string `json:"rootdevicetype,omitempty"` - Securitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Egressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"egressrule,omitempty"` - Id string `json:"id,omitempty"` - Ingressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"ingressrule,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinecount int `json:"virtualmachinecount,omitempty"` - Virtualmachineids []string `json:"virtualmachineids,omitempty"` - } `json:"securitygroup,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - Servicestate string `json:"servicestate,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatedisplaytext string `json:"templatedisplaytext,omitempty"` - Templateid string `json:"templateid,omitempty"` - Templatename string `json:"templatename,omitempty"` - Userid string `json:"userid,omitempty"` - Username string `json:"username,omitempty"` - Vgpu string `json:"vgpu,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type MigrateVirtualMachineParams struct { - p map[string]interface{} -} - -func (p *MigrateVirtualMachineParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["hostid"]; found { - u.Set("hostid", v.(string)) - } - if v, found := p.p["storageid"]; found { - u.Set("storageid", v.(string)) - } - if v, found := p.p["virtualmachineid"]; found { - u.Set("virtualmachineid", v.(string)) - } - return u -} - -func (p *MigrateVirtualMachineParams) SetHostid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hostid"] = v - return -} - -func (p *MigrateVirtualMachineParams) SetStorageid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["storageid"] = v - return -} - -func (p *MigrateVirtualMachineParams) SetVirtualmachineid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["virtualmachineid"] = v - return -} - -// You should always use this function to get a new MigrateVirtualMachineParams instance, -// as then you are sure you have configured all required params -func (s *VirtualMachineService) NewMigrateVirtualMachineParams(virtualmachineid string) *MigrateVirtualMachineParams { - p := &MigrateVirtualMachineParams{} - p.p = make(map[string]interface{}) - p.p["virtualmachineid"] = virtualmachineid - return p -} - -// Attempts Migration of a VM to a different host or Root volume of the vm to a different storage pool -func (s *VirtualMachineService) MigrateVirtualMachine(p *MigrateVirtualMachineParams) (*MigrateVirtualMachineResponse, error) { - resp, err := s.cs.newRequest("migrateVirtualMachine", p.toURLValues()) - if err != nil { - return nil, err - } - - var r MigrateVirtualMachineResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type MigrateVirtualMachineResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Affinitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Type string `json:"type,omitempty"` - VirtualmachineIds []string `json:"virtualmachineIds,omitempty"` - } `json:"affinitygroup,omitempty"` - Cpunumber int `json:"cpunumber,omitempty"` - Cpuspeed int `json:"cpuspeed,omitempty"` - Cpuused string `json:"cpuused,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Diskioread int64 `json:"diskioread,omitempty"` - Diskiowrite int64 `json:"diskiowrite,omitempty"` - Diskkbsread int64 `json:"diskkbsread,omitempty"` - Diskkbswrite int64 `json:"diskkbswrite,omitempty"` - Diskofferingid string `json:"diskofferingid,omitempty"` - Diskofferingname string `json:"diskofferingname,omitempty"` - Displayname string `json:"displayname,omitempty"` - Displayvm bool `json:"displayvm,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"` - Group string `json:"group,omitempty"` - Groupid string `json:"groupid,omitempty"` - Guestosid string `json:"guestosid,omitempty"` - Haenable bool `json:"haenable,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Instancename string `json:"instancename,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isodisplaytext string `json:"isodisplaytext,omitempty"` - Isoid string `json:"isoid,omitempty"` - Isoname string `json:"isoname,omitempty"` - Keypair string `json:"keypair,omitempty"` - Memory int `json:"memory,omitempty"` - Name string `json:"name,omitempty"` - Networkkbsread int64 `json:"networkkbsread,omitempty"` - Networkkbswrite int64 `json:"networkkbswrite,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Ostypeid int64 `json:"ostypeid,omitempty"` - Password string `json:"password,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - Rootdeviceid int64 `json:"rootdeviceid,omitempty"` - Rootdevicetype string `json:"rootdevicetype,omitempty"` - Securitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Egressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"egressrule,omitempty"` - Id string `json:"id,omitempty"` - Ingressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"ingressrule,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinecount int `json:"virtualmachinecount,omitempty"` - Virtualmachineids []string `json:"virtualmachineids,omitempty"` - } `json:"securitygroup,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - Servicestate string `json:"servicestate,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatedisplaytext string `json:"templatedisplaytext,omitempty"` - Templateid string `json:"templateid,omitempty"` - Templatename string `json:"templatename,omitempty"` - Userid string `json:"userid,omitempty"` - Username string `json:"username,omitempty"` - Vgpu string `json:"vgpu,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type MigrateVirtualMachineWithVolumeParams struct { - p map[string]interface{} -} - -func (p *MigrateVirtualMachineWithVolumeParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["hostid"]; found { - u.Set("hostid", v.(string)) - } - if v, found := p.p["migrateto"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("migrateto[%d].key", i), k) - u.Set(fmt.Sprintf("migrateto[%d].value", i), vv) - i++ - } - } - if v, found := p.p["virtualmachineid"]; found { - u.Set("virtualmachineid", v.(string)) - } - return u -} - -func (p *MigrateVirtualMachineWithVolumeParams) SetHostid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hostid"] = v - return -} - -func (p *MigrateVirtualMachineWithVolumeParams) SetMigrateto(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["migrateto"] = v - return -} - -func (p *MigrateVirtualMachineWithVolumeParams) SetVirtualmachineid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["virtualmachineid"] = v - return -} - -// You should always use this function to get a new MigrateVirtualMachineWithVolumeParams instance, -// as then you are sure you have configured all required params -func (s *VirtualMachineService) NewMigrateVirtualMachineWithVolumeParams(hostid string, virtualmachineid string) *MigrateVirtualMachineWithVolumeParams { - p := &MigrateVirtualMachineWithVolumeParams{} - p.p = make(map[string]interface{}) - p.p["hostid"] = hostid - p.p["virtualmachineid"] = virtualmachineid - return p -} - -// Attempts Migration of a VM with its volumes to a different host -func (s *VirtualMachineService) MigrateVirtualMachineWithVolume(p *MigrateVirtualMachineWithVolumeParams) (*MigrateVirtualMachineWithVolumeResponse, error) { - resp, err := s.cs.newRequest("migrateVirtualMachineWithVolume", p.toURLValues()) - if err != nil { - return nil, err - } - - var r MigrateVirtualMachineWithVolumeResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type MigrateVirtualMachineWithVolumeResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Affinitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Type string `json:"type,omitempty"` - VirtualmachineIds []string `json:"virtualmachineIds,omitempty"` - } `json:"affinitygroup,omitempty"` - Cpunumber int `json:"cpunumber,omitempty"` - Cpuspeed int `json:"cpuspeed,omitempty"` - Cpuused string `json:"cpuused,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Diskioread int64 `json:"diskioread,omitempty"` - Diskiowrite int64 `json:"diskiowrite,omitempty"` - Diskkbsread int64 `json:"diskkbsread,omitempty"` - Diskkbswrite int64 `json:"diskkbswrite,omitempty"` - Diskofferingid string `json:"diskofferingid,omitempty"` - Diskofferingname string `json:"diskofferingname,omitempty"` - Displayname string `json:"displayname,omitempty"` - Displayvm bool `json:"displayvm,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"` - Group string `json:"group,omitempty"` - Groupid string `json:"groupid,omitempty"` - Guestosid string `json:"guestosid,omitempty"` - Haenable bool `json:"haenable,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Instancename string `json:"instancename,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isodisplaytext string `json:"isodisplaytext,omitempty"` - Isoid string `json:"isoid,omitempty"` - Isoname string `json:"isoname,omitempty"` - Keypair string `json:"keypair,omitempty"` - Memory int `json:"memory,omitempty"` - Name string `json:"name,omitempty"` - Networkkbsread int64 `json:"networkkbsread,omitempty"` - Networkkbswrite int64 `json:"networkkbswrite,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Ostypeid int64 `json:"ostypeid,omitempty"` - Password string `json:"password,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - Rootdeviceid int64 `json:"rootdeviceid,omitempty"` - Rootdevicetype string `json:"rootdevicetype,omitempty"` - Securitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Egressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"egressrule,omitempty"` - Id string `json:"id,omitempty"` - Ingressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"ingressrule,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinecount int `json:"virtualmachinecount,omitempty"` - Virtualmachineids []string `json:"virtualmachineids,omitempty"` - } `json:"securitygroup,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - Servicestate string `json:"servicestate,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatedisplaytext string `json:"templatedisplaytext,omitempty"` - Templateid string `json:"templateid,omitempty"` - Templatename string `json:"templatename,omitempty"` - Userid string `json:"userid,omitempty"` - Username string `json:"username,omitempty"` - Vgpu string `json:"vgpu,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type RecoverVirtualMachineParams struct { - p map[string]interface{} -} - -func (p *RecoverVirtualMachineParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *RecoverVirtualMachineParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new RecoverVirtualMachineParams instance, -// as then you are sure you have configured all required params -func (s *VirtualMachineService) NewRecoverVirtualMachineParams(id string) *RecoverVirtualMachineParams { - p := &RecoverVirtualMachineParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Recovers a virtual machine. -func (s *VirtualMachineService) RecoverVirtualMachine(p *RecoverVirtualMachineParams) (*RecoverVirtualMachineResponse, error) { - resp, err := s.cs.newRequest("recoverVirtualMachine", p.toURLValues()) - if err != nil { - return nil, err - } - - var r RecoverVirtualMachineResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type RecoverVirtualMachineResponse struct { - Account string `json:"account,omitempty"` - Affinitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Type string `json:"type,omitempty"` - VirtualmachineIds []string `json:"virtualmachineIds,omitempty"` - } `json:"affinitygroup,omitempty"` - Cpunumber int `json:"cpunumber,omitempty"` - Cpuspeed int `json:"cpuspeed,omitempty"` - Cpuused string `json:"cpuused,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Diskioread int64 `json:"diskioread,omitempty"` - Diskiowrite int64 `json:"diskiowrite,omitempty"` - Diskkbsread int64 `json:"diskkbsread,omitempty"` - Diskkbswrite int64 `json:"diskkbswrite,omitempty"` - Diskofferingid string `json:"diskofferingid,omitempty"` - Diskofferingname string `json:"diskofferingname,omitempty"` - Displayname string `json:"displayname,omitempty"` - Displayvm bool `json:"displayvm,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"` - Group string `json:"group,omitempty"` - Groupid string `json:"groupid,omitempty"` - Guestosid string `json:"guestosid,omitempty"` - Haenable bool `json:"haenable,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Instancename string `json:"instancename,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isodisplaytext string `json:"isodisplaytext,omitempty"` - Isoid string `json:"isoid,omitempty"` - Isoname string `json:"isoname,omitempty"` - Keypair string `json:"keypair,omitempty"` - Memory int `json:"memory,omitempty"` - Name string `json:"name,omitempty"` - Networkkbsread int64 `json:"networkkbsread,omitempty"` - Networkkbswrite int64 `json:"networkkbswrite,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Ostypeid int64 `json:"ostypeid,omitempty"` - Password string `json:"password,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - Rootdeviceid int64 `json:"rootdeviceid,omitempty"` - Rootdevicetype string `json:"rootdevicetype,omitempty"` - Securitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Egressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"egressrule,omitempty"` - Id string `json:"id,omitempty"` - Ingressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"ingressrule,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinecount int `json:"virtualmachinecount,omitempty"` - Virtualmachineids []string `json:"virtualmachineids,omitempty"` - } `json:"securitygroup,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - Servicestate string `json:"servicestate,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatedisplaytext string `json:"templatedisplaytext,omitempty"` - Templateid string `json:"templateid,omitempty"` - Templatename string `json:"templatename,omitempty"` - Userid string `json:"userid,omitempty"` - Username string `json:"username,omitempty"` - Vgpu string `json:"vgpu,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type ExpungeVirtualMachineParams struct { - p map[string]interface{} -} - -func (p *ExpungeVirtualMachineParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *ExpungeVirtualMachineParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new ExpungeVirtualMachineParams instance, -// as then you are sure you have configured all required params -func (s *VirtualMachineService) NewExpungeVirtualMachineParams(id string) *ExpungeVirtualMachineParams { - p := &ExpungeVirtualMachineParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Expunge a virtual machine. Once expunged, it cannot be recoverd. -func (s *VirtualMachineService) ExpungeVirtualMachine(p *ExpungeVirtualMachineParams) (*ExpungeVirtualMachineResponse, error) { - resp, err := s.cs.newRequest("expungeVirtualMachine", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ExpungeVirtualMachineResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type ExpungeVirtualMachineResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type CleanVMReservationsParams struct { - p map[string]interface{} -} - -func (p *CleanVMReservationsParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - return u -} - -// You should always use this function to get a new CleanVMReservationsParams instance, -// as then you are sure you have configured all required params -func (s *VirtualMachineService) NewCleanVMReservationsParams() *CleanVMReservationsParams { - p := &CleanVMReservationsParams{} - p.p = make(map[string]interface{}) - return p -} - -// Cleanups VM reservations in the database. -func (s *VirtualMachineService) CleanVMReservations(p *CleanVMReservationsParams) (*CleanVMReservationsResponse, error) { - resp, err := s.cs.newRequest("cleanVMReservations", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CleanVMReservationsResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CleanVMReservationsResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type AddNicToVirtualMachineParams struct { - p map[string]interface{} -} - -func (p *AddNicToVirtualMachineParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["ipaddress"]; found { - u.Set("ipaddress", v.(string)) - } - if v, found := p.p["networkid"]; found { - u.Set("networkid", v.(string)) - } - if v, found := p.p["virtualmachineid"]; found { - u.Set("virtualmachineid", v.(string)) - } - return u -} - -func (p *AddNicToVirtualMachineParams) SetIpaddress(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ipaddress"] = v - return -} - -func (p *AddNicToVirtualMachineParams) SetNetworkid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networkid"] = v - return -} - -func (p *AddNicToVirtualMachineParams) SetVirtualmachineid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["virtualmachineid"] = v - return -} - -// You should always use this function to get a new AddNicToVirtualMachineParams instance, -// as then you are sure you have configured all required params -func (s *VirtualMachineService) NewAddNicToVirtualMachineParams(networkid string, virtualmachineid string) *AddNicToVirtualMachineParams { - p := &AddNicToVirtualMachineParams{} - p.p = make(map[string]interface{}) - p.p["networkid"] = networkid - p.p["virtualmachineid"] = virtualmachineid - return p -} - -// Adds VM to specified network by creating a NIC -func (s *VirtualMachineService) AddNicToVirtualMachine(p *AddNicToVirtualMachineParams) (*AddNicToVirtualMachineResponse, error) { - resp, err := s.cs.newRequest("addNicToVirtualMachine", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AddNicToVirtualMachineResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type AddNicToVirtualMachineResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Affinitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Type string `json:"type,omitempty"` - VirtualmachineIds []string `json:"virtualmachineIds,omitempty"` - } `json:"affinitygroup,omitempty"` - Cpunumber int `json:"cpunumber,omitempty"` - Cpuspeed int `json:"cpuspeed,omitempty"` - Cpuused string `json:"cpuused,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Diskioread int64 `json:"diskioread,omitempty"` - Diskiowrite int64 `json:"diskiowrite,omitempty"` - Diskkbsread int64 `json:"diskkbsread,omitempty"` - Diskkbswrite int64 `json:"diskkbswrite,omitempty"` - Diskofferingid string `json:"diskofferingid,omitempty"` - Diskofferingname string `json:"diskofferingname,omitempty"` - Displayname string `json:"displayname,omitempty"` - Displayvm bool `json:"displayvm,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"` - Group string `json:"group,omitempty"` - Groupid string `json:"groupid,omitempty"` - Guestosid string `json:"guestosid,omitempty"` - Haenable bool `json:"haenable,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Instancename string `json:"instancename,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isodisplaytext string `json:"isodisplaytext,omitempty"` - Isoid string `json:"isoid,omitempty"` - Isoname string `json:"isoname,omitempty"` - Keypair string `json:"keypair,omitempty"` - Memory int `json:"memory,omitempty"` - Name string `json:"name,omitempty"` - Networkkbsread int64 `json:"networkkbsread,omitempty"` - Networkkbswrite int64 `json:"networkkbswrite,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Ostypeid int64 `json:"ostypeid,omitempty"` - Password string `json:"password,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - Rootdeviceid int64 `json:"rootdeviceid,omitempty"` - Rootdevicetype string `json:"rootdevicetype,omitempty"` - Securitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Egressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"egressrule,omitempty"` - Id string `json:"id,omitempty"` - Ingressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"ingressrule,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinecount int `json:"virtualmachinecount,omitempty"` - Virtualmachineids []string `json:"virtualmachineids,omitempty"` - } `json:"securitygroup,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - Servicestate string `json:"servicestate,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatedisplaytext string `json:"templatedisplaytext,omitempty"` - Templateid string `json:"templateid,omitempty"` - Templatename string `json:"templatename,omitempty"` - Userid string `json:"userid,omitempty"` - Username string `json:"username,omitempty"` - Vgpu string `json:"vgpu,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type RemoveNicFromVirtualMachineParams struct { - p map[string]interface{} -} - -func (p *RemoveNicFromVirtualMachineParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["nicid"]; found { - u.Set("nicid", v.(string)) - } - if v, found := p.p["virtualmachineid"]; found { - u.Set("virtualmachineid", v.(string)) - } - return u -} - -func (p *RemoveNicFromVirtualMachineParams) SetNicid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["nicid"] = v - return -} - -func (p *RemoveNicFromVirtualMachineParams) SetVirtualmachineid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["virtualmachineid"] = v - return -} - -// You should always use this function to get a new RemoveNicFromVirtualMachineParams instance, -// as then you are sure you have configured all required params -func (s *VirtualMachineService) NewRemoveNicFromVirtualMachineParams(nicid string, virtualmachineid string) *RemoveNicFromVirtualMachineParams { - p := &RemoveNicFromVirtualMachineParams{} - p.p = make(map[string]interface{}) - p.p["nicid"] = nicid - p.p["virtualmachineid"] = virtualmachineid - return p -} - -// Removes VM from specified network by deleting a NIC -func (s *VirtualMachineService) RemoveNicFromVirtualMachine(p *RemoveNicFromVirtualMachineParams) (*RemoveNicFromVirtualMachineResponse, error) { - resp, err := s.cs.newRequest("removeNicFromVirtualMachine", p.toURLValues()) - if err != nil { - return nil, err - } - - var r RemoveNicFromVirtualMachineResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type RemoveNicFromVirtualMachineResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Affinitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Type string `json:"type,omitempty"` - VirtualmachineIds []string `json:"virtualmachineIds,omitempty"` - } `json:"affinitygroup,omitempty"` - Cpunumber int `json:"cpunumber,omitempty"` - Cpuspeed int `json:"cpuspeed,omitempty"` - Cpuused string `json:"cpuused,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Diskioread int64 `json:"diskioread,omitempty"` - Diskiowrite int64 `json:"diskiowrite,omitempty"` - Diskkbsread int64 `json:"diskkbsread,omitempty"` - Diskkbswrite int64 `json:"diskkbswrite,omitempty"` - Diskofferingid string `json:"diskofferingid,omitempty"` - Diskofferingname string `json:"diskofferingname,omitempty"` - Displayname string `json:"displayname,omitempty"` - Displayvm bool `json:"displayvm,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"` - Group string `json:"group,omitempty"` - Groupid string `json:"groupid,omitempty"` - Guestosid string `json:"guestosid,omitempty"` - Haenable bool `json:"haenable,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Instancename string `json:"instancename,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isodisplaytext string `json:"isodisplaytext,omitempty"` - Isoid string `json:"isoid,omitempty"` - Isoname string `json:"isoname,omitempty"` - Keypair string `json:"keypair,omitempty"` - Memory int `json:"memory,omitempty"` - Name string `json:"name,omitempty"` - Networkkbsread int64 `json:"networkkbsread,omitempty"` - Networkkbswrite int64 `json:"networkkbswrite,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Ostypeid int64 `json:"ostypeid,omitempty"` - Password string `json:"password,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - Rootdeviceid int64 `json:"rootdeviceid,omitempty"` - Rootdevicetype string `json:"rootdevicetype,omitempty"` - Securitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Egressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"egressrule,omitempty"` - Id string `json:"id,omitempty"` - Ingressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"ingressrule,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinecount int `json:"virtualmachinecount,omitempty"` - Virtualmachineids []string `json:"virtualmachineids,omitempty"` - } `json:"securitygroup,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - Servicestate string `json:"servicestate,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatedisplaytext string `json:"templatedisplaytext,omitempty"` - Templateid string `json:"templateid,omitempty"` - Templatename string `json:"templatename,omitempty"` - Userid string `json:"userid,omitempty"` - Username string `json:"username,omitempty"` - Vgpu string `json:"vgpu,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type UpdateDefaultNicForVirtualMachineParams struct { - p map[string]interface{} -} - -func (p *UpdateDefaultNicForVirtualMachineParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["nicid"]; found { - u.Set("nicid", v.(string)) - } - if v, found := p.p["virtualmachineid"]; found { - u.Set("virtualmachineid", v.(string)) - } - return u -} - -func (p *UpdateDefaultNicForVirtualMachineParams) SetNicid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["nicid"] = v - return -} - -func (p *UpdateDefaultNicForVirtualMachineParams) SetVirtualmachineid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["virtualmachineid"] = v - return -} - -// You should always use this function to get a new UpdateDefaultNicForVirtualMachineParams instance, -// as then you are sure you have configured all required params -func (s *VirtualMachineService) NewUpdateDefaultNicForVirtualMachineParams(nicid string, virtualmachineid string) *UpdateDefaultNicForVirtualMachineParams { - p := &UpdateDefaultNicForVirtualMachineParams{} - p.p = make(map[string]interface{}) - p.p["nicid"] = nicid - p.p["virtualmachineid"] = virtualmachineid - return p -} - -// Changes the default NIC on a VM -func (s *VirtualMachineService) UpdateDefaultNicForVirtualMachine(p *UpdateDefaultNicForVirtualMachineParams) (*UpdateDefaultNicForVirtualMachineResponse, error) { - resp, err := s.cs.newRequest("updateDefaultNicForVirtualMachine", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateDefaultNicForVirtualMachineResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateDefaultNicForVirtualMachineResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Affinitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Type string `json:"type,omitempty"` - VirtualmachineIds []string `json:"virtualmachineIds,omitempty"` - } `json:"affinitygroup,omitempty"` - Cpunumber int `json:"cpunumber,omitempty"` - Cpuspeed int `json:"cpuspeed,omitempty"` - Cpuused string `json:"cpuused,omitempty"` - Created string `json:"created,omitempty"` - Details map[string]string `json:"details,omitempty"` - Diskioread int64 `json:"diskioread,omitempty"` - Diskiowrite int64 `json:"diskiowrite,omitempty"` - Diskkbsread int64 `json:"diskkbsread,omitempty"` - Diskkbswrite int64 `json:"diskkbswrite,omitempty"` - Diskofferingid string `json:"diskofferingid,omitempty"` - Diskofferingname string `json:"diskofferingname,omitempty"` - Displayname string `json:"displayname,omitempty"` - Displayvm bool `json:"displayvm,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"` - Group string `json:"group,omitempty"` - Groupid string `json:"groupid,omitempty"` - Guestosid string `json:"guestosid,omitempty"` - Haenable bool `json:"haenable,omitempty"` - Hostid string `json:"hostid,omitempty"` - Hostname string `json:"hostname,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Instancename string `json:"instancename,omitempty"` - Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"` - Isodisplaytext string `json:"isodisplaytext,omitempty"` - Isoid string `json:"isoid,omitempty"` - Isoname string `json:"isoname,omitempty"` - Keypair string `json:"keypair,omitempty"` - Memory int `json:"memory,omitempty"` - Name string `json:"name,omitempty"` - Networkkbsread int64 `json:"networkkbsread,omitempty"` - Networkkbswrite int64 `json:"networkkbswrite,omitempty"` - Nic []struct { - Broadcasturi string `json:"broadcasturi,omitempty"` - Deviceid string `json:"deviceid,omitempty"` - Gateway string `json:"gateway,omitempty"` - Id string `json:"id,omitempty"` - Ip6address string `json:"ip6address,omitempty"` - Ip6cidr string `json:"ip6cidr,omitempty"` - Ip6gateway string `json:"ip6gateway,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - Isdefault bool `json:"isdefault,omitempty"` - Isolationuri string `json:"isolationuri,omitempty"` - Macaddress string `json:"macaddress,omitempty"` - Netmask string `json:"netmask,omitempty"` - Networkid string `json:"networkid,omitempty"` - Networkname string `json:"networkname,omitempty"` - Secondaryip []struct { - Id string `json:"id,omitempty"` - Ipaddress string `json:"ipaddress,omitempty"` - } `json:"secondaryip,omitempty"` - Traffictype string `json:"traffictype,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - } `json:"nic,omitempty"` - Ostypeid int64 `json:"ostypeid,omitempty"` - Password string `json:"password,omitempty"` - Passwordenabled bool `json:"passwordenabled,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Publicip string `json:"publicip,omitempty"` - Publicipid string `json:"publicipid,omitempty"` - Rootdeviceid int64 `json:"rootdeviceid,omitempty"` - Rootdevicetype string `json:"rootdevicetype,omitempty"` - Securitygroup []struct { - Account string `json:"account,omitempty"` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Egressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"egressrule,omitempty"` - Id string `json:"id,omitempty"` - Ingressrule []struct { - Account string `json:"account,omitempty"` - Cidr string `json:"cidr,omitempty"` - Endport int `json:"endport,omitempty"` - Icmpcode int `json:"icmpcode,omitempty"` - Icmptype int `json:"icmptype,omitempty"` - Protocol string `json:"protocol,omitempty"` - Ruleid string `json:"ruleid,omitempty"` - Securitygroupname string `json:"securitygroupname,omitempty"` - Startport int `json:"startport,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - } `json:"ingressrule,omitempty"` - Name string `json:"name,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Virtualmachinecount int `json:"virtualmachinecount,omitempty"` - Virtualmachineids []string `json:"virtualmachineids,omitempty"` - } `json:"securitygroup,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - Servicestate string `json:"servicestate,omitempty"` - State string `json:"state,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatedisplaytext string `json:"templatedisplaytext,omitempty"` - Templateid string `json:"templateid,omitempty"` - Templatename string `json:"templatename,omitempty"` - Userid string `json:"userid,omitempty"` - Username string `json:"username,omitempty"` - Vgpu string `json:"vgpu,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/VolumeService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/VolumeService.go deleted file mode 100644 index 2072969c3ac..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/VolumeService.go +++ /dev/null @@ -1,2275 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type AttachVolumeParams struct { - p map[string]interface{} -} - -func (p *AttachVolumeParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["deviceid"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("deviceid", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["virtualmachineid"]; found { - u.Set("virtualmachineid", v.(string)) - } - return u -} - -func (p *AttachVolumeParams) SetDeviceid(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["deviceid"] = v - return -} - -func (p *AttachVolumeParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *AttachVolumeParams) SetVirtualmachineid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["virtualmachineid"] = v - return -} - -// You should always use this function to get a new AttachVolumeParams instance, -// as then you are sure you have configured all required params -func (s *VolumeService) NewAttachVolumeParams(id string, virtualmachineid string) *AttachVolumeParams { - p := &AttachVolumeParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - p.p["virtualmachineid"] = virtualmachineid - return p -} - -// Attaches a disk volume to a virtual machine. -func (s *VolumeService) AttachVolume(p *AttachVolumeParams) (*AttachVolumeResponse, error) { - resp, err := s.cs.newRequest("attachVolume", p.toURLValues()) - if err != nil { - return nil, err - } - - var r AttachVolumeResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type AttachVolumeResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Attached string `json:"attached,omitempty"` - Chaininfo string `json:"chaininfo,omitempty"` - Created string `json:"created,omitempty"` - Destroyed bool `json:"destroyed,omitempty"` - Deviceid int64 `json:"deviceid,omitempty"` - DiskBytesReadRate int64 `json:"diskBytesReadRate,omitempty"` - DiskBytesWriteRate int64 `json:"diskBytesWriteRate,omitempty"` - DiskIopsReadRate int64 `json:"diskIopsReadRate,omitempty"` - DiskIopsWriteRate int64 `json:"diskIopsWriteRate,omitempty"` - Diskofferingdisplaytext string `json:"diskofferingdisplaytext,omitempty"` - Diskofferingid string `json:"diskofferingid,omitempty"` - Diskofferingname string `json:"diskofferingname,omitempty"` - Displayvolume bool `json:"displayvolume,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Isextractable bool `json:"isextractable,omitempty"` - Isodisplaytext string `json:"isodisplaytext,omitempty"` - Isoid string `json:"isoid,omitempty"` - Isoname string `json:"isoname,omitempty"` - Maxiops int64 `json:"maxiops,omitempty"` - Miniops int64 `json:"miniops,omitempty"` - Name string `json:"name,omitempty"` - Path string `json:"path,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Provisioningtype string `json:"provisioningtype,omitempty"` - Quiescevm bool `json:"quiescevm,omitempty"` - Serviceofferingdisplaytext string `json:"serviceofferingdisplaytext,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - Size int64 `json:"size,omitempty"` - Snapshotid string `json:"snapshotid,omitempty"` - State string `json:"state,omitempty"` - Status string `json:"status,omitempty"` - Storage string `json:"storage,omitempty"` - Storageid string `json:"storageid,omitempty"` - Storagetype string `json:"storagetype,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatedisplaytext string `json:"templatedisplaytext,omitempty"` - Templateid string `json:"templateid,omitempty"` - Templatename string `json:"templatename,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - Vmdisplayname string `json:"vmdisplayname,omitempty"` - Vmname string `json:"vmname,omitempty"` - Vmstate string `json:"vmstate,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type UploadVolumeParams struct { - p map[string]interface{} -} - -func (p *UploadVolumeParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["checksum"]; found { - u.Set("checksum", v.(string)) - } - if v, found := p.p["diskofferingid"]; found { - u.Set("diskofferingid", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["format"]; found { - u.Set("format", v.(string)) - } - if v, found := p.p["imagestoreuuid"]; found { - u.Set("imagestoreuuid", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["url"]; found { - u.Set("url", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *UploadVolumeParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *UploadVolumeParams) SetChecksum(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["checksum"] = v - return -} - -func (p *UploadVolumeParams) SetDiskofferingid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["diskofferingid"] = v - return -} - -func (p *UploadVolumeParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *UploadVolumeParams) SetFormat(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["format"] = v - return -} - -func (p *UploadVolumeParams) SetImagestoreuuid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["imagestoreuuid"] = v - return -} - -func (p *UploadVolumeParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *UploadVolumeParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *UploadVolumeParams) SetUrl(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["url"] = v - return -} - -func (p *UploadVolumeParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new UploadVolumeParams instance, -// as then you are sure you have configured all required params -func (s *VolumeService) NewUploadVolumeParams(format string, name string, url string, zoneid string) *UploadVolumeParams { - p := &UploadVolumeParams{} - p.p = make(map[string]interface{}) - p.p["format"] = format - p.p["name"] = name - p.p["url"] = url - p.p["zoneid"] = zoneid - return p -} - -// Uploads a data disk. -func (s *VolumeService) UploadVolume(p *UploadVolumeParams) (*UploadVolumeResponse, error) { - resp, err := s.cs.newRequest("uploadVolume", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UploadVolumeResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UploadVolumeResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Attached string `json:"attached,omitempty"` - Chaininfo string `json:"chaininfo,omitempty"` - Created string `json:"created,omitempty"` - Destroyed bool `json:"destroyed,omitempty"` - Deviceid int64 `json:"deviceid,omitempty"` - DiskBytesReadRate int64 `json:"diskBytesReadRate,omitempty"` - DiskBytesWriteRate int64 `json:"diskBytesWriteRate,omitempty"` - DiskIopsReadRate int64 `json:"diskIopsReadRate,omitempty"` - DiskIopsWriteRate int64 `json:"diskIopsWriteRate,omitempty"` - Diskofferingdisplaytext string `json:"diskofferingdisplaytext,omitempty"` - Diskofferingid string `json:"diskofferingid,omitempty"` - Diskofferingname string `json:"diskofferingname,omitempty"` - Displayvolume bool `json:"displayvolume,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Isextractable bool `json:"isextractable,omitempty"` - Isodisplaytext string `json:"isodisplaytext,omitempty"` - Isoid string `json:"isoid,omitempty"` - Isoname string `json:"isoname,omitempty"` - Maxiops int64 `json:"maxiops,omitempty"` - Miniops int64 `json:"miniops,omitempty"` - Name string `json:"name,omitempty"` - Path string `json:"path,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Provisioningtype string `json:"provisioningtype,omitempty"` - Quiescevm bool `json:"quiescevm,omitempty"` - Serviceofferingdisplaytext string `json:"serviceofferingdisplaytext,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - Size int64 `json:"size,omitempty"` - Snapshotid string `json:"snapshotid,omitempty"` - State string `json:"state,omitempty"` - Status string `json:"status,omitempty"` - Storage string `json:"storage,omitempty"` - Storageid string `json:"storageid,omitempty"` - Storagetype string `json:"storagetype,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatedisplaytext string `json:"templatedisplaytext,omitempty"` - Templateid string `json:"templateid,omitempty"` - Templatename string `json:"templatename,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - Vmdisplayname string `json:"vmdisplayname,omitempty"` - Vmname string `json:"vmname,omitempty"` - Vmstate string `json:"vmstate,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type DetachVolumeParams struct { - p map[string]interface{} -} - -func (p *DetachVolumeParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["deviceid"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("deviceid", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["virtualmachineid"]; found { - u.Set("virtualmachineid", v.(string)) - } - return u -} - -func (p *DetachVolumeParams) SetDeviceid(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["deviceid"] = v - return -} - -func (p *DetachVolumeParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *DetachVolumeParams) SetVirtualmachineid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["virtualmachineid"] = v - return -} - -// You should always use this function to get a new DetachVolumeParams instance, -// as then you are sure you have configured all required params -func (s *VolumeService) NewDetachVolumeParams() *DetachVolumeParams { - p := &DetachVolumeParams{} - p.p = make(map[string]interface{}) - return p -} - -// Detaches a disk volume from a virtual machine. -func (s *VolumeService) DetachVolume(p *DetachVolumeParams) (*DetachVolumeResponse, error) { - resp, err := s.cs.newRequest("detachVolume", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DetachVolumeResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DetachVolumeResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Attached string `json:"attached,omitempty"` - Chaininfo string `json:"chaininfo,omitempty"` - Created string `json:"created,omitempty"` - Destroyed bool `json:"destroyed,omitempty"` - Deviceid int64 `json:"deviceid,omitempty"` - DiskBytesReadRate int64 `json:"diskBytesReadRate,omitempty"` - DiskBytesWriteRate int64 `json:"diskBytesWriteRate,omitempty"` - DiskIopsReadRate int64 `json:"diskIopsReadRate,omitempty"` - DiskIopsWriteRate int64 `json:"diskIopsWriteRate,omitempty"` - Diskofferingdisplaytext string `json:"diskofferingdisplaytext,omitempty"` - Diskofferingid string `json:"diskofferingid,omitempty"` - Diskofferingname string `json:"diskofferingname,omitempty"` - Displayvolume bool `json:"displayvolume,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Isextractable bool `json:"isextractable,omitempty"` - Isodisplaytext string `json:"isodisplaytext,omitempty"` - Isoid string `json:"isoid,omitempty"` - Isoname string `json:"isoname,omitempty"` - Maxiops int64 `json:"maxiops,omitempty"` - Miniops int64 `json:"miniops,omitempty"` - Name string `json:"name,omitempty"` - Path string `json:"path,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Provisioningtype string `json:"provisioningtype,omitempty"` - Quiescevm bool `json:"quiescevm,omitempty"` - Serviceofferingdisplaytext string `json:"serviceofferingdisplaytext,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - Size int64 `json:"size,omitempty"` - Snapshotid string `json:"snapshotid,omitempty"` - State string `json:"state,omitempty"` - Status string `json:"status,omitempty"` - Storage string `json:"storage,omitempty"` - Storageid string `json:"storageid,omitempty"` - Storagetype string `json:"storagetype,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatedisplaytext string `json:"templatedisplaytext,omitempty"` - Templateid string `json:"templateid,omitempty"` - Templatename string `json:"templatename,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - Vmdisplayname string `json:"vmdisplayname,omitempty"` - Vmname string `json:"vmname,omitempty"` - Vmstate string `json:"vmstate,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type CreateVolumeParams struct { - p map[string]interface{} -} - -func (p *CreateVolumeParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["customid"]; found { - u.Set("customid", v.(string)) - } - if v, found := p.p["diskofferingid"]; found { - u.Set("diskofferingid", v.(string)) - } - if v, found := p.p["displayvolume"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("displayvolume", vv) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["maxiops"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("maxiops", vv) - } - if v, found := p.p["miniops"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("miniops", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["size"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("size", vv) - } - if v, found := p.p["snapshotid"]; found { - u.Set("snapshotid", v.(string)) - } - if v, found := p.p["virtualmachineid"]; found { - u.Set("virtualmachineid", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *CreateVolumeParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *CreateVolumeParams) SetCustomid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["customid"] = v - return -} - -func (p *CreateVolumeParams) SetDiskofferingid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["diskofferingid"] = v - return -} - -func (p *CreateVolumeParams) SetDisplayvolume(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displayvolume"] = v - return -} - -func (p *CreateVolumeParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *CreateVolumeParams) SetMaxiops(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["maxiops"] = v - return -} - -func (p *CreateVolumeParams) SetMiniops(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["miniops"] = v - return -} - -func (p *CreateVolumeParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *CreateVolumeParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *CreateVolumeParams) SetSize(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["size"] = v - return -} - -func (p *CreateVolumeParams) SetSnapshotid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["snapshotid"] = v - return -} - -func (p *CreateVolumeParams) SetVirtualmachineid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["virtualmachineid"] = v - return -} - -func (p *CreateVolumeParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new CreateVolumeParams instance, -// as then you are sure you have configured all required params -func (s *VolumeService) NewCreateVolumeParams() *CreateVolumeParams { - p := &CreateVolumeParams{} - p.p = make(map[string]interface{}) - return p -} - -// Creates a disk volume from a disk offering. This disk volume must still be attached to a virtual machine to make use of it. -func (s *VolumeService) CreateVolume(p *CreateVolumeParams) (*CreateVolumeResponse, error) { - resp, err := s.cs.newRequest("createVolume", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateVolumeResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type CreateVolumeResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Attached string `json:"attached,omitempty"` - Chaininfo string `json:"chaininfo,omitempty"` - Created string `json:"created,omitempty"` - Destroyed bool `json:"destroyed,omitempty"` - Deviceid int64 `json:"deviceid,omitempty"` - DiskBytesReadRate int64 `json:"diskBytesReadRate,omitempty"` - DiskBytesWriteRate int64 `json:"diskBytesWriteRate,omitempty"` - DiskIopsReadRate int64 `json:"diskIopsReadRate,omitempty"` - DiskIopsWriteRate int64 `json:"diskIopsWriteRate,omitempty"` - Diskofferingdisplaytext string `json:"diskofferingdisplaytext,omitempty"` - Diskofferingid string `json:"diskofferingid,omitempty"` - Diskofferingname string `json:"diskofferingname,omitempty"` - Displayvolume bool `json:"displayvolume,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Isextractable bool `json:"isextractable,omitempty"` - Isodisplaytext string `json:"isodisplaytext,omitempty"` - Isoid string `json:"isoid,omitempty"` - Isoname string `json:"isoname,omitempty"` - Maxiops int64 `json:"maxiops,omitempty"` - Miniops int64 `json:"miniops,omitempty"` - Name string `json:"name,omitempty"` - Path string `json:"path,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Provisioningtype string `json:"provisioningtype,omitempty"` - Quiescevm bool `json:"quiescevm,omitempty"` - Serviceofferingdisplaytext string `json:"serviceofferingdisplaytext,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - Size int64 `json:"size,omitempty"` - Snapshotid string `json:"snapshotid,omitempty"` - State string `json:"state,omitempty"` - Status string `json:"status,omitempty"` - Storage string `json:"storage,omitempty"` - Storageid string `json:"storageid,omitempty"` - Storagetype string `json:"storagetype,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatedisplaytext string `json:"templatedisplaytext,omitempty"` - Templateid string `json:"templateid,omitempty"` - Templatename string `json:"templatename,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - Vmdisplayname string `json:"vmdisplayname,omitempty"` - Vmname string `json:"vmname,omitempty"` - Vmstate string `json:"vmstate,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type DeleteVolumeParams struct { - p map[string]interface{} -} - -func (p *DeleteVolumeParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteVolumeParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteVolumeParams instance, -// as then you are sure you have configured all required params -func (s *VolumeService) NewDeleteVolumeParams(id string) *DeleteVolumeParams { - p := &DeleteVolumeParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a detached disk volume. -func (s *VolumeService) DeleteVolume(p *DeleteVolumeParams) (*DeleteVolumeResponse, error) { - resp, err := s.cs.newRequest("deleteVolume", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteVolumeResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type DeleteVolumeResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} - -type ListVolumesParams struct { - p map[string]interface{} -} - -func (p *ListVolumesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["diskofferingid"]; found { - u.Set("diskofferingid", v.(string)) - } - if v, found := p.p["displayvolume"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("displayvolume", vv) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["hostid"]; found { - u.Set("hostid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["isrecursive"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("isrecursive", vv) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["listall"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("listall", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["podid"]; found { - u.Set("podid", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["storageid"]; found { - u.Set("storageid", v.(string)) - } - if v, found := p.p["tags"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("tags[%d].key", i), k) - u.Set(fmt.Sprintf("tags[%d].value", i), vv) - i++ - } - } - if v, found := p.p["type"]; found { - u.Set("type", v.(string)) - } - if v, found := p.p["virtualmachineid"]; found { - u.Set("virtualmachineid", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ListVolumesParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListVolumesParams) SetDiskofferingid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["diskofferingid"] = v - return -} - -func (p *ListVolumesParams) SetDisplayvolume(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displayvolume"] = v - return -} - -func (p *ListVolumesParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListVolumesParams) SetHostid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["hostid"] = v - return -} - -func (p *ListVolumesParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListVolumesParams) SetIsrecursive(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["isrecursive"] = v - return -} - -func (p *ListVolumesParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListVolumesParams) SetListall(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["listall"] = v - return -} - -func (p *ListVolumesParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListVolumesParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListVolumesParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListVolumesParams) SetPodid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["podid"] = v - return -} - -func (p *ListVolumesParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *ListVolumesParams) SetStorageid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["storageid"] = v - return -} - -func (p *ListVolumesParams) SetTags(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tags"] = v - return -} - -func (p *ListVolumesParams) SetType(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["volumeType"] = v - return -} - -func (p *ListVolumesParams) SetVirtualmachineid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["virtualmachineid"] = v - return -} - -func (p *ListVolumesParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ListVolumesParams instance, -// as then you are sure you have configured all required params -func (s *VolumeService) NewListVolumesParams() *ListVolumesParams { - p := &ListVolumesParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *VolumeService) GetVolumeID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListVolumesParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListVolumes(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.Volumes[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.Volumes { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *VolumeService) GetVolumeByName(name string, opts ...OptionFunc) (*Volume, int, error) { - id, count, err := s.GetVolumeID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetVolumeByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *VolumeService) GetVolumeByID(id string, opts ...OptionFunc) (*Volume, int, error) { - p := &ListVolumesParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListVolumes(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.Volumes[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for Volume UUID: %s!", id) -} - -// Lists all volumes. -func (s *VolumeService) ListVolumes(p *ListVolumesParams) (*ListVolumesResponse, error) { - resp, err := s.cs.newRequest("listVolumes", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListVolumesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListVolumesResponse struct { - Count int `json:"count"` - Volumes []*Volume `json:"volume"` -} - -type Volume struct { - Account string `json:"account,omitempty"` - Attached string `json:"attached,omitempty"` - Chaininfo string `json:"chaininfo,omitempty"` - Created string `json:"created,omitempty"` - Destroyed bool `json:"destroyed,omitempty"` - Deviceid int64 `json:"deviceid,omitempty"` - DiskBytesReadRate int64 `json:"diskBytesReadRate,omitempty"` - DiskBytesWriteRate int64 `json:"diskBytesWriteRate,omitempty"` - DiskIopsReadRate int64 `json:"diskIopsReadRate,omitempty"` - DiskIopsWriteRate int64 `json:"diskIopsWriteRate,omitempty"` - Diskofferingdisplaytext string `json:"diskofferingdisplaytext,omitempty"` - Diskofferingid string `json:"diskofferingid,omitempty"` - Diskofferingname string `json:"diskofferingname,omitempty"` - Displayvolume bool `json:"displayvolume,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Isextractable bool `json:"isextractable,omitempty"` - Isodisplaytext string `json:"isodisplaytext,omitempty"` - Isoid string `json:"isoid,omitempty"` - Isoname string `json:"isoname,omitempty"` - Maxiops int64 `json:"maxiops,omitempty"` - Miniops int64 `json:"miniops,omitempty"` - Name string `json:"name,omitempty"` - Path string `json:"path,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Provisioningtype string `json:"provisioningtype,omitempty"` - Quiescevm bool `json:"quiescevm,omitempty"` - Serviceofferingdisplaytext string `json:"serviceofferingdisplaytext,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - Size int64 `json:"size,omitempty"` - Snapshotid string `json:"snapshotid,omitempty"` - State string `json:"state,omitempty"` - Status string `json:"status,omitempty"` - Storage string `json:"storage,omitempty"` - Storageid string `json:"storageid,omitempty"` - Storagetype string `json:"storagetype,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatedisplaytext string `json:"templatedisplaytext,omitempty"` - Templateid string `json:"templateid,omitempty"` - Templatename string `json:"templatename,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - Vmdisplayname string `json:"vmdisplayname,omitempty"` - Vmname string `json:"vmname,omitempty"` - Vmstate string `json:"vmstate,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type ExtractVolumeParams struct { - p map[string]interface{} -} - -func (p *ExtractVolumeParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["mode"]; found { - u.Set("mode", v.(string)) - } - if v, found := p.p["url"]; found { - u.Set("url", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ExtractVolumeParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ExtractVolumeParams) SetMode(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["mode"] = v - return -} - -func (p *ExtractVolumeParams) SetUrl(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["url"] = v - return -} - -func (p *ExtractVolumeParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ExtractVolumeParams instance, -// as then you are sure you have configured all required params -func (s *VolumeService) NewExtractVolumeParams(id string, mode string, zoneid string) *ExtractVolumeParams { - p := &ExtractVolumeParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - p.p["mode"] = mode - p.p["zoneid"] = zoneid - return p -} - -// Extracts volume -func (s *VolumeService) ExtractVolume(p *ExtractVolumeParams) (*ExtractVolumeResponse, error) { - resp, err := s.cs.newRequest("extractVolume", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ExtractVolumeResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type ExtractVolumeResponse struct { - JobID string `json:"jobid,omitempty"` - Accountid string `json:"accountid,omitempty"` - Created string `json:"created,omitempty"` - ExtractId string `json:"extractId,omitempty"` - ExtractMode string `json:"extractMode,omitempty"` - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Resultstring string `json:"resultstring,omitempty"` - State string `json:"state,omitempty"` - Status string `json:"status,omitempty"` - Storagetype string `json:"storagetype,omitempty"` - Uploadpercentage int `json:"uploadpercentage,omitempty"` - Url string `json:"url,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type MigrateVolumeParams struct { - p map[string]interface{} -} - -func (p *MigrateVolumeParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["livemigrate"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("livemigrate", vv) - } - if v, found := p.p["storageid"]; found { - u.Set("storageid", v.(string)) - } - if v, found := p.p["volumeid"]; found { - u.Set("volumeid", v.(string)) - } - return u -} - -func (p *MigrateVolumeParams) SetLivemigrate(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["livemigrate"] = v - return -} - -func (p *MigrateVolumeParams) SetStorageid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["storageid"] = v - return -} - -func (p *MigrateVolumeParams) SetVolumeid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["volumeid"] = v - return -} - -// You should always use this function to get a new MigrateVolumeParams instance, -// as then you are sure you have configured all required params -func (s *VolumeService) NewMigrateVolumeParams(storageid string, volumeid string) *MigrateVolumeParams { - p := &MigrateVolumeParams{} - p.p = make(map[string]interface{}) - p.p["storageid"] = storageid - p.p["volumeid"] = volumeid - return p -} - -// Migrate volume -func (s *VolumeService) MigrateVolume(p *MigrateVolumeParams) (*MigrateVolumeResponse, error) { - resp, err := s.cs.newRequest("migrateVolume", p.toURLValues()) - if err != nil { - return nil, err - } - - var r MigrateVolumeResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type MigrateVolumeResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Attached string `json:"attached,omitempty"` - Chaininfo string `json:"chaininfo,omitempty"` - Created string `json:"created,omitempty"` - Destroyed bool `json:"destroyed,omitempty"` - Deviceid int64 `json:"deviceid,omitempty"` - DiskBytesReadRate int64 `json:"diskBytesReadRate,omitempty"` - DiskBytesWriteRate int64 `json:"diskBytesWriteRate,omitempty"` - DiskIopsReadRate int64 `json:"diskIopsReadRate,omitempty"` - DiskIopsWriteRate int64 `json:"diskIopsWriteRate,omitempty"` - Diskofferingdisplaytext string `json:"diskofferingdisplaytext,omitempty"` - Diskofferingid string `json:"diskofferingid,omitempty"` - Diskofferingname string `json:"diskofferingname,omitempty"` - Displayvolume bool `json:"displayvolume,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Isextractable bool `json:"isextractable,omitempty"` - Isodisplaytext string `json:"isodisplaytext,omitempty"` - Isoid string `json:"isoid,omitempty"` - Isoname string `json:"isoname,omitempty"` - Maxiops int64 `json:"maxiops,omitempty"` - Miniops int64 `json:"miniops,omitempty"` - Name string `json:"name,omitempty"` - Path string `json:"path,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Provisioningtype string `json:"provisioningtype,omitempty"` - Quiescevm bool `json:"quiescevm,omitempty"` - Serviceofferingdisplaytext string `json:"serviceofferingdisplaytext,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - Size int64 `json:"size,omitempty"` - Snapshotid string `json:"snapshotid,omitempty"` - State string `json:"state,omitempty"` - Status string `json:"status,omitempty"` - Storage string `json:"storage,omitempty"` - Storageid string `json:"storageid,omitempty"` - Storagetype string `json:"storagetype,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatedisplaytext string `json:"templatedisplaytext,omitempty"` - Templateid string `json:"templateid,omitempty"` - Templatename string `json:"templatename,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - Vmdisplayname string `json:"vmdisplayname,omitempty"` - Vmname string `json:"vmname,omitempty"` - Vmstate string `json:"vmstate,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type ResizeVolumeParams struct { - p map[string]interface{} -} - -func (p *ResizeVolumeParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["diskofferingid"]; found { - u.Set("diskofferingid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["maxiops"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("maxiops", vv) - } - if v, found := p.p["miniops"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("miniops", vv) - } - if v, found := p.p["shrinkok"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("shrinkok", vv) - } - if v, found := p.p["size"]; found { - vv := strconv.FormatInt(v.(int64), 10) - u.Set("size", vv) - } - return u -} - -func (p *ResizeVolumeParams) SetDiskofferingid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["diskofferingid"] = v - return -} - -func (p *ResizeVolumeParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ResizeVolumeParams) SetMaxiops(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["maxiops"] = v - return -} - -func (p *ResizeVolumeParams) SetMiniops(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["miniops"] = v - return -} - -func (p *ResizeVolumeParams) SetShrinkok(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["shrinkok"] = v - return -} - -func (p *ResizeVolumeParams) SetSize(v int64) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["size"] = v - return -} - -// You should always use this function to get a new ResizeVolumeParams instance, -// as then you are sure you have configured all required params -func (s *VolumeService) NewResizeVolumeParams(id string) *ResizeVolumeParams { - p := &ResizeVolumeParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Resizes a volume -func (s *VolumeService) ResizeVolume(p *ResizeVolumeParams) (*ResizeVolumeResponse, error) { - resp, err := s.cs.newRequest("resizeVolume", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ResizeVolumeResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type ResizeVolumeResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Attached string `json:"attached,omitempty"` - Chaininfo string `json:"chaininfo,omitempty"` - Created string `json:"created,omitempty"` - Destroyed bool `json:"destroyed,omitempty"` - Deviceid int64 `json:"deviceid,omitempty"` - DiskBytesReadRate int64 `json:"diskBytesReadRate,omitempty"` - DiskBytesWriteRate int64 `json:"diskBytesWriteRate,omitempty"` - DiskIopsReadRate int64 `json:"diskIopsReadRate,omitempty"` - DiskIopsWriteRate int64 `json:"diskIopsWriteRate,omitempty"` - Diskofferingdisplaytext string `json:"diskofferingdisplaytext,omitempty"` - Diskofferingid string `json:"diskofferingid,omitempty"` - Diskofferingname string `json:"diskofferingname,omitempty"` - Displayvolume bool `json:"displayvolume,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Isextractable bool `json:"isextractable,omitempty"` - Isodisplaytext string `json:"isodisplaytext,omitempty"` - Isoid string `json:"isoid,omitempty"` - Isoname string `json:"isoname,omitempty"` - Maxiops int64 `json:"maxiops,omitempty"` - Miniops int64 `json:"miniops,omitempty"` - Name string `json:"name,omitempty"` - Path string `json:"path,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Provisioningtype string `json:"provisioningtype,omitempty"` - Quiescevm bool `json:"quiescevm,omitempty"` - Serviceofferingdisplaytext string `json:"serviceofferingdisplaytext,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - Size int64 `json:"size,omitempty"` - Snapshotid string `json:"snapshotid,omitempty"` - State string `json:"state,omitempty"` - Status string `json:"status,omitempty"` - Storage string `json:"storage,omitempty"` - Storageid string `json:"storageid,omitempty"` - Storagetype string `json:"storagetype,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatedisplaytext string `json:"templatedisplaytext,omitempty"` - Templateid string `json:"templateid,omitempty"` - Templatename string `json:"templatename,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - Vmdisplayname string `json:"vmdisplayname,omitempty"` - Vmname string `json:"vmname,omitempty"` - Vmstate string `json:"vmstate,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type UpdateVolumeParams struct { - p map[string]interface{} -} - -func (p *UpdateVolumeParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["chaininfo"]; found { - u.Set("chaininfo", v.(string)) - } - if v, found := p.p["customid"]; found { - u.Set("customid", v.(string)) - } - if v, found := p.p["displayvolume"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("displayvolume", vv) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["path"]; found { - u.Set("path", v.(string)) - } - if v, found := p.p["state"]; found { - u.Set("state", v.(string)) - } - if v, found := p.p["storageid"]; found { - u.Set("storageid", v.(string)) - } - return u -} - -func (p *UpdateVolumeParams) SetChaininfo(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["chaininfo"] = v - return -} - -func (p *UpdateVolumeParams) SetCustomid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["customid"] = v - return -} - -func (p *UpdateVolumeParams) SetDisplayvolume(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["displayvolume"] = v - return -} - -func (p *UpdateVolumeParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateVolumeParams) SetPath(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["path"] = v - return -} - -func (p *UpdateVolumeParams) SetState(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["state"] = v - return -} - -func (p *UpdateVolumeParams) SetStorageid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["storageid"] = v - return -} - -// You should always use this function to get a new UpdateVolumeParams instance, -// as then you are sure you have configured all required params -func (s *VolumeService) NewUpdateVolumeParams() *UpdateVolumeParams { - p := &UpdateVolumeParams{} - p.p = make(map[string]interface{}) - return p -} - -// Updates the volume. -func (s *VolumeService) UpdateVolume(p *UpdateVolumeParams) (*UpdateVolumeResponse, error) { - resp, err := s.cs.newRequest("updateVolume", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateVolumeResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type UpdateVolumeResponse struct { - JobID string `json:"jobid,omitempty"` - Account string `json:"account,omitempty"` - Attached string `json:"attached,omitempty"` - Chaininfo string `json:"chaininfo,omitempty"` - Created string `json:"created,omitempty"` - Destroyed bool `json:"destroyed,omitempty"` - Deviceid int64 `json:"deviceid,omitempty"` - DiskBytesReadRate int64 `json:"diskBytesReadRate,omitempty"` - DiskBytesWriteRate int64 `json:"diskBytesWriteRate,omitempty"` - DiskIopsReadRate int64 `json:"diskIopsReadRate,omitempty"` - DiskIopsWriteRate int64 `json:"diskIopsWriteRate,omitempty"` - Diskofferingdisplaytext string `json:"diskofferingdisplaytext,omitempty"` - Diskofferingid string `json:"diskofferingid,omitempty"` - Diskofferingname string `json:"diskofferingname,omitempty"` - Displayvolume bool `json:"displayvolume,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Hypervisor string `json:"hypervisor,omitempty"` - Id string `json:"id,omitempty"` - Isextractable bool `json:"isextractable,omitempty"` - Isodisplaytext string `json:"isodisplaytext,omitempty"` - Isoid string `json:"isoid,omitempty"` - Isoname string `json:"isoname,omitempty"` - Maxiops int64 `json:"maxiops,omitempty"` - Miniops int64 `json:"miniops,omitempty"` - Name string `json:"name,omitempty"` - Path string `json:"path,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Provisioningtype string `json:"provisioningtype,omitempty"` - Quiescevm bool `json:"quiescevm,omitempty"` - Serviceofferingdisplaytext string `json:"serviceofferingdisplaytext,omitempty"` - Serviceofferingid string `json:"serviceofferingid,omitempty"` - Serviceofferingname string `json:"serviceofferingname,omitempty"` - Size int64 `json:"size,omitempty"` - Snapshotid string `json:"snapshotid,omitempty"` - State string `json:"state,omitempty"` - Status string `json:"status,omitempty"` - Storage string `json:"storage,omitempty"` - Storageid string `json:"storageid,omitempty"` - Storagetype string `json:"storagetype,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Templatedisplaytext string `json:"templatedisplaytext,omitempty"` - Templateid string `json:"templateid,omitempty"` - Templatename string `json:"templatename,omitempty"` - Type string `json:"type,omitempty"` - Virtualmachineid string `json:"virtualmachineid,omitempty"` - Vmdisplayname string `json:"vmdisplayname,omitempty"` - Vmname string `json:"vmname,omitempty"` - Vmstate string `json:"vmstate,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type GetSolidFireVolumeSizeParams struct { - p map[string]interface{} -} - -func (p *GetSolidFireVolumeSizeParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["storageid"]; found { - u.Set("storageid", v.(string)) - } - if v, found := p.p["volumeid"]; found { - u.Set("volumeid", v.(string)) - } - return u -} - -func (p *GetSolidFireVolumeSizeParams) SetStorageid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["storageid"] = v - return -} - -func (p *GetSolidFireVolumeSizeParams) SetVolumeid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["volumeid"] = v - return -} - -// You should always use this function to get a new GetSolidFireVolumeSizeParams instance, -// as then you are sure you have configured all required params -func (s *VolumeService) NewGetSolidFireVolumeSizeParams(storageid string, volumeid string) *GetSolidFireVolumeSizeParams { - p := &GetSolidFireVolumeSizeParams{} - p.p = make(map[string]interface{}) - p.p["storageid"] = storageid - p.p["volumeid"] = volumeid - return p -} - -// Get the SF volume size including Hypervisor Snapshot Reserve -func (s *VolumeService) GetSolidFireVolumeSize(p *GetSolidFireVolumeSizeParams) (*GetSolidFireVolumeSizeResponse, error) { - resp, err := s.cs.newRequest("getSolidFireVolumeSize", p.toURLValues()) - if err != nil { - return nil, err - } - - var r GetSolidFireVolumeSizeResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type GetSolidFireVolumeSizeResponse struct { - SolidFireVolumeSize int64 `json:"solidFireVolumeSize,omitempty"` -} - -type GetSolidFireVolumeAccessGroupIdParams struct { - p map[string]interface{} -} - -func (p *GetSolidFireVolumeAccessGroupIdParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["clusterid"]; found { - u.Set("clusterid", v.(string)) - } - if v, found := p.p["storageid"]; found { - u.Set("storageid", v.(string)) - } - return u -} - -func (p *GetSolidFireVolumeAccessGroupIdParams) SetClusterid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["clusterid"] = v - return -} - -func (p *GetSolidFireVolumeAccessGroupIdParams) SetStorageid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["storageid"] = v - return -} - -// You should always use this function to get a new GetSolidFireVolumeAccessGroupIdParams instance, -// as then you are sure you have configured all required params -func (s *VolumeService) NewGetSolidFireVolumeAccessGroupIdParams(clusterid string, storageid string) *GetSolidFireVolumeAccessGroupIdParams { - p := &GetSolidFireVolumeAccessGroupIdParams{} - p.p = make(map[string]interface{}) - p.p["clusterid"] = clusterid - p.p["storageid"] = storageid - return p -} - -// Get the SF Volume Access Group ID -func (s *VolumeService) GetSolidFireVolumeAccessGroupId(p *GetSolidFireVolumeAccessGroupIdParams) (*GetSolidFireVolumeAccessGroupIdResponse, error) { - resp, err := s.cs.newRequest("getSolidFireVolumeAccessGroupId", p.toURLValues()) - if err != nil { - return nil, err - } - - var r GetSolidFireVolumeAccessGroupIdResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type GetSolidFireVolumeAccessGroupIdResponse struct { - SolidFireVolumeAccessGroupId int64 `json:"solidFireVolumeAccessGroupId,omitempty"` -} - -type GetSolidFireVolumeIscsiNameParams struct { - p map[string]interface{} -} - -func (p *GetSolidFireVolumeIscsiNameParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["volumeid"]; found { - u.Set("volumeid", v.(string)) - } - return u -} - -func (p *GetSolidFireVolumeIscsiNameParams) SetVolumeid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["volumeid"] = v - return -} - -// You should always use this function to get a new GetSolidFireVolumeIscsiNameParams instance, -// as then you are sure you have configured all required params -func (s *VolumeService) NewGetSolidFireVolumeIscsiNameParams(volumeid string) *GetSolidFireVolumeIscsiNameParams { - p := &GetSolidFireVolumeIscsiNameParams{} - p.p = make(map[string]interface{}) - p.p["volumeid"] = volumeid - return p -} - -// Get SolidFire Volume's Iscsi Name -func (s *VolumeService) GetSolidFireVolumeIscsiName(p *GetSolidFireVolumeIscsiNameParams) (*GetSolidFireVolumeIscsiNameResponse, error) { - resp, err := s.cs.newRequest("getSolidFireVolumeIscsiName", p.toURLValues()) - if err != nil { - return nil, err - } - - var r GetSolidFireVolumeIscsiNameResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type GetSolidFireVolumeIscsiNameResponse struct { - SolidFireVolumeIscsiName string `json:"solidFireVolumeIscsiName,omitempty"` -} - -type GetUploadParamsForVolumeParams struct { - p map[string]interface{} -} - -func (p *GetUploadParamsForVolumeParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["checksum"]; found { - u.Set("checksum", v.(string)) - } - if v, found := p.p["diskofferingid"]; found { - u.Set("diskofferingid", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["format"]; found { - u.Set("format", v.(string)) - } - if v, found := p.p["imagestoreuuid"]; found { - u.Set("imagestoreuuid", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["projectid"]; found { - u.Set("projectid", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *GetUploadParamsForVolumeParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *GetUploadParamsForVolumeParams) SetChecksum(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["checksum"] = v - return -} - -func (p *GetUploadParamsForVolumeParams) SetDiskofferingid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["diskofferingid"] = v - return -} - -func (p *GetUploadParamsForVolumeParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *GetUploadParamsForVolumeParams) SetFormat(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["format"] = v - return -} - -func (p *GetUploadParamsForVolumeParams) SetImagestoreuuid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["imagestoreuuid"] = v - return -} - -func (p *GetUploadParamsForVolumeParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *GetUploadParamsForVolumeParams) SetProjectid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["projectid"] = v - return -} - -func (p *GetUploadParamsForVolumeParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new GetUploadParamsForVolumeParams instance, -// as then you are sure you have configured all required params -func (s *VolumeService) NewGetUploadParamsForVolumeParams(format string, name string, zoneid string) *GetUploadParamsForVolumeParams { - p := &GetUploadParamsForVolumeParams{} - p.p = make(map[string]interface{}) - p.p["format"] = format - p.p["name"] = name - p.p["zoneid"] = zoneid - return p -} - -// Upload a data disk to the cloudstack cloud. -func (s *VolumeService) GetUploadParamsForVolume(p *GetUploadParamsForVolumeParams) (*GetUploadParamsForVolumeResponse, error) { - resp, err := s.cs.newRequest("getUploadParamsForVolume", p.toURLValues()) - if err != nil { - return nil, err - } - - var r GetUploadParamsForVolumeResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type GetUploadParamsForVolumeResponse struct { - Expires string `json:"expires,omitempty"` - Id string `json:"id,omitempty"` - Metadata string `json:"metadata,omitempty"` - PostURL string `json:"postURL,omitempty"` - Signature string `json:"signature,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/ZoneService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/ZoneService.go deleted file mode 100644 index d02e4dcd752..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/ZoneService.go +++ /dev/null @@ -1,1167 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "encoding/json" - "fmt" - "net/url" - "strconv" - "strings" -) - -type CreateZoneParams struct { - p map[string]interface{} -} - -func (p *CreateZoneParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["allocationstate"]; found { - u.Set("allocationstate", v.(string)) - } - if v, found := p.p["dns1"]; found { - u.Set("dns1", v.(string)) - } - if v, found := p.p["dns2"]; found { - u.Set("dns2", v.(string)) - } - if v, found := p.p["domain"]; found { - u.Set("domain", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["guestcidraddress"]; found { - u.Set("guestcidraddress", v.(string)) - } - if v, found := p.p["internaldns1"]; found { - u.Set("internaldns1", v.(string)) - } - if v, found := p.p["internaldns2"]; found { - u.Set("internaldns2", v.(string)) - } - if v, found := p.p["ip6dns1"]; found { - u.Set("ip6dns1", v.(string)) - } - if v, found := p.p["ip6dns2"]; found { - u.Set("ip6dns2", v.(string)) - } - if v, found := p.p["localstorageenabled"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("localstorageenabled", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["networktype"]; found { - u.Set("networktype", v.(string)) - } - if v, found := p.p["securitygroupenabled"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("securitygroupenabled", vv) - } - return u -} - -func (p *CreateZoneParams) SetAllocationstate(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["allocationstate"] = v - return -} - -func (p *CreateZoneParams) SetDns1(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["dns1"] = v - return -} - -func (p *CreateZoneParams) SetDns2(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["dns2"] = v - return -} - -func (p *CreateZoneParams) SetDomain(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domain"] = v - return -} - -func (p *CreateZoneParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *CreateZoneParams) SetGuestcidraddress(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["guestcidraddress"] = v - return -} - -func (p *CreateZoneParams) SetInternaldns1(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["internaldns1"] = v - return -} - -func (p *CreateZoneParams) SetInternaldns2(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["internaldns2"] = v - return -} - -func (p *CreateZoneParams) SetIp6dns1(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ip6dns1"] = v - return -} - -func (p *CreateZoneParams) SetIp6dns2(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ip6dns2"] = v - return -} - -func (p *CreateZoneParams) SetLocalstorageenabled(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["localstorageenabled"] = v - return -} - -func (p *CreateZoneParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *CreateZoneParams) SetNetworktype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networktype"] = v - return -} - -func (p *CreateZoneParams) SetSecuritygroupenabled(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["securitygroupenabled"] = v - return -} - -// You should always use this function to get a new CreateZoneParams instance, -// as then you are sure you have configured all required params -func (s *ZoneService) NewCreateZoneParams(dns1 string, internaldns1 string, name string, networktype string) *CreateZoneParams { - p := &CreateZoneParams{} - p.p = make(map[string]interface{}) - p.p["dns1"] = dns1 - p.p["internaldns1"] = internaldns1 - p.p["name"] = name - p.p["networktype"] = networktype - return p -} - -// Creates a Zone. -func (s *ZoneService) CreateZone(p *CreateZoneParams) (*CreateZoneResponse, error) { - resp, err := s.cs.newRequest("createZone", p.toURLValues()) - if err != nil { - return nil, err - } - - var r CreateZoneResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type CreateZoneResponse struct { - Allocationstate string `json:"allocationstate,omitempty"` - Capacity []struct { - Capacitytotal int64 `json:"capacitytotal,omitempty"` - Capacityused int64 `json:"capacityused,omitempty"` - Clusterid string `json:"clusterid,omitempty"` - Clustername string `json:"clustername,omitempty"` - Percentused string `json:"percentused,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` - Type int `json:"type,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` - } `json:"capacity,omitempty"` - Description string `json:"description,omitempty"` - Dhcpprovider string `json:"dhcpprovider,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Dns1 string `json:"dns1,omitempty"` - Dns2 string `json:"dns2,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Domainname string `json:"domainname,omitempty"` - Guestcidraddress string `json:"guestcidraddress,omitempty"` - Id string `json:"id,omitempty"` - Internaldns1 string `json:"internaldns1,omitempty"` - Internaldns2 string `json:"internaldns2,omitempty"` - Ip6dns1 string `json:"ip6dns1,omitempty"` - Ip6dns2 string `json:"ip6dns2,omitempty"` - Localstorageenabled bool `json:"localstorageenabled,omitempty"` - Name string `json:"name,omitempty"` - Networktype string `json:"networktype,omitempty"` - Resourcedetails map[string]string `json:"resourcedetails,omitempty"` - Securitygroupsenabled bool `json:"securitygroupsenabled,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Zonetoken string `json:"zonetoken,omitempty"` -} - -type UpdateZoneParams struct { - p map[string]interface{} -} - -func (p *UpdateZoneParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["allocationstate"]; found { - u.Set("allocationstate", v.(string)) - } - if v, found := p.p["details"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("details[%d].key", i), k) - u.Set(fmt.Sprintf("details[%d].value", i), vv) - i++ - } - } - if v, found := p.p["dhcpprovider"]; found { - u.Set("dhcpprovider", v.(string)) - } - if v, found := p.p["dns1"]; found { - u.Set("dns1", v.(string)) - } - if v, found := p.p["dns2"]; found { - u.Set("dns2", v.(string)) - } - if v, found := p.p["dnssearchorder"]; found { - vv := strings.Join(v.([]string), ",") - u.Set("dnssearchorder", vv) - } - if v, found := p.p["domain"]; found { - u.Set("domain", v.(string)) - } - if v, found := p.p["guestcidraddress"]; found { - u.Set("guestcidraddress", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["internaldns1"]; found { - u.Set("internaldns1", v.(string)) - } - if v, found := p.p["internaldns2"]; found { - u.Set("internaldns2", v.(string)) - } - if v, found := p.p["ip6dns1"]; found { - u.Set("ip6dns1", v.(string)) - } - if v, found := p.p["ip6dns2"]; found { - u.Set("ip6dns2", v.(string)) - } - if v, found := p.p["ispublic"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("ispublic", vv) - } - if v, found := p.p["localstorageenabled"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("localstorageenabled", vv) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - return u -} - -func (p *UpdateZoneParams) SetAllocationstate(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["allocationstate"] = v - return -} - -func (p *UpdateZoneParams) SetDetails(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["details"] = v - return -} - -func (p *UpdateZoneParams) SetDhcpprovider(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["dhcpprovider"] = v - return -} - -func (p *UpdateZoneParams) SetDns1(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["dns1"] = v - return -} - -func (p *UpdateZoneParams) SetDns2(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["dns2"] = v - return -} - -func (p *UpdateZoneParams) SetDnssearchorder(v []string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["dnssearchorder"] = v - return -} - -func (p *UpdateZoneParams) SetDomain(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domain"] = v - return -} - -func (p *UpdateZoneParams) SetGuestcidraddress(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["guestcidraddress"] = v - return -} - -func (p *UpdateZoneParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *UpdateZoneParams) SetInternaldns1(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["internaldns1"] = v - return -} - -func (p *UpdateZoneParams) SetInternaldns2(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["internaldns2"] = v - return -} - -func (p *UpdateZoneParams) SetIp6dns1(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ip6dns1"] = v - return -} - -func (p *UpdateZoneParams) SetIp6dns2(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ip6dns2"] = v - return -} - -func (p *UpdateZoneParams) SetIspublic(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["ispublic"] = v - return -} - -func (p *UpdateZoneParams) SetLocalstorageenabled(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["localstorageenabled"] = v - return -} - -func (p *UpdateZoneParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -// You should always use this function to get a new UpdateZoneParams instance, -// as then you are sure you have configured all required params -func (s *ZoneService) NewUpdateZoneParams(id string) *UpdateZoneParams { - p := &UpdateZoneParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Updates a Zone. -func (s *ZoneService) UpdateZone(p *UpdateZoneParams) (*UpdateZoneResponse, error) { - resp, err := s.cs.newRequest("updateZone", p.toURLValues()) - if err != nil { - return nil, err - } - - var r UpdateZoneResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type UpdateZoneResponse struct { - Allocationstate string `json:"allocationstate,omitempty"` - Capacity []struct { - Capacitytotal int64 `json:"capacitytotal,omitempty"` - Capacityused int64 `json:"capacityused,omitempty"` - Clusterid string `json:"clusterid,omitempty"` - Clustername string `json:"clustername,omitempty"` - Percentused string `json:"percentused,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` - Type int `json:"type,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` - } `json:"capacity,omitempty"` - Description string `json:"description,omitempty"` - Dhcpprovider string `json:"dhcpprovider,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Dns1 string `json:"dns1,omitempty"` - Dns2 string `json:"dns2,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Domainname string `json:"domainname,omitempty"` - Guestcidraddress string `json:"guestcidraddress,omitempty"` - Id string `json:"id,omitempty"` - Internaldns1 string `json:"internaldns1,omitempty"` - Internaldns2 string `json:"internaldns2,omitempty"` - Ip6dns1 string `json:"ip6dns1,omitempty"` - Ip6dns2 string `json:"ip6dns2,omitempty"` - Localstorageenabled bool `json:"localstorageenabled,omitempty"` - Name string `json:"name,omitempty"` - Networktype string `json:"networktype,omitempty"` - Resourcedetails map[string]string `json:"resourcedetails,omitempty"` - Securitygroupsenabled bool `json:"securitygroupsenabled,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Zonetoken string `json:"zonetoken,omitempty"` -} - -type DeleteZoneParams struct { - p map[string]interface{} -} - -func (p *DeleteZoneParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - return u -} - -func (p *DeleteZoneParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -// You should always use this function to get a new DeleteZoneParams instance, -// as then you are sure you have configured all required params -func (s *ZoneService) NewDeleteZoneParams(id string) *DeleteZoneParams { - p := &DeleteZoneParams{} - p.p = make(map[string]interface{}) - p.p["id"] = id - return p -} - -// Deletes a Zone. -func (s *ZoneService) DeleteZone(p *DeleteZoneParams) (*DeleteZoneResponse, error) { - resp, err := s.cs.newRequest("deleteZone", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DeleteZoneResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type DeleteZoneResponse struct { - Displaytext string `json:"displaytext,omitempty"` - Success string `json:"success,omitempty"` -} - -type ListZonesParams struct { - p map[string]interface{} -} - -func (p *ListZonesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["available"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("available", vv) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["id"]; found { - u.Set("id", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["name"]; found { - u.Set("name", v.(string)) - } - if v, found := p.p["networktype"]; found { - u.Set("networktype", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["showcapacities"]; found { - vv := strconv.FormatBool(v.(bool)) - u.Set("showcapacities", vv) - } - if v, found := p.p["tags"]; found { - i := 0 - for k, vv := range v.(map[string]string) { - u.Set(fmt.Sprintf("tags[%d].key", i), k) - u.Set(fmt.Sprintf("tags[%d].value", i), vv) - i++ - } - } - return u -} - -func (p *ListZonesParams) SetAvailable(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["available"] = v - return -} - -func (p *ListZonesParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListZonesParams) SetId(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["id"] = v - return -} - -func (p *ListZonesParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListZonesParams) SetName(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["name"] = v - return -} - -func (p *ListZonesParams) SetNetworktype(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["networktype"] = v - return -} - -func (p *ListZonesParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListZonesParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListZonesParams) SetShowcapacities(v bool) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["showcapacities"] = v - return -} - -func (p *ListZonesParams) SetTags(v map[string]string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["tags"] = v - return -} - -// You should always use this function to get a new ListZonesParams instance, -// as then you are sure you have configured all required params -func (s *ZoneService) NewListZonesParams() *ListZonesParams { - p := &ListZonesParams{} - p.p = make(map[string]interface{}) - return p -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *ZoneService) GetZoneID(name string, opts ...OptionFunc) (string, int, error) { - p := &ListZonesParams{} - p.p = make(map[string]interface{}) - - p.p["name"] = name - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return "", -1, err - } - } - - l, err := s.ListZones(p) - if err != nil { - return "", -1, err - } - - if l.Count == 0 { - return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l) - } - - if l.Count == 1 { - return l.Zones[0].Id, l.Count, nil - } - - if l.Count > 1 { - for _, v := range l.Zones { - if v.Name == name { - return v.Id, l.Count, nil - } - } - } - return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l) -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *ZoneService) GetZoneByName(name string, opts ...OptionFunc) (*Zone, int, error) { - id, count, err := s.GetZoneID(name, opts...) - if err != nil { - return nil, count, err - } - - r, count, err := s.GetZoneByID(id, opts...) - if err != nil { - return nil, count, err - } - return r, count, nil -} - -// This is a courtesy helper function, which in some cases may not work as expected! -func (s *ZoneService) GetZoneByID(id string, opts ...OptionFunc) (*Zone, int, error) { - p := &ListZonesParams{} - p.p = make(map[string]interface{}) - - p.p["id"] = id - - for _, fn := range opts { - if err := fn(s.cs, p); err != nil { - return nil, -1, err - } - } - - l, err := s.ListZones(p) - if err != nil { - if strings.Contains(err.Error(), fmt.Sprintf( - "Invalid parameter id value=%s due to incorrect long value format, "+ - "or entity does not exist", id)) { - return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) - } - return nil, -1, err - } - - if l.Count == 0 { - return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) - } - - if l.Count == 1 { - return l.Zones[0], l.Count, nil - } - return nil, l.Count, fmt.Errorf("There is more then one result for Zone UUID: %s!", id) -} - -// Lists zones -func (s *ZoneService) ListZones(p *ListZonesParams) (*ListZonesResponse, error) { - resp, err := s.cs.newRequest("listZones", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListZonesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListZonesResponse struct { - Count int `json:"count"` - Zones []*Zone `json:"zone"` -} - -type Zone struct { - Allocationstate string `json:"allocationstate,omitempty"` - Capacity []struct { - Capacitytotal int64 `json:"capacitytotal,omitempty"` - Capacityused int64 `json:"capacityused,omitempty"` - Clusterid string `json:"clusterid,omitempty"` - Clustername string `json:"clustername,omitempty"` - Percentused string `json:"percentused,omitempty"` - Podid string `json:"podid,omitempty"` - Podname string `json:"podname,omitempty"` - Type int `json:"type,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` - } `json:"capacity,omitempty"` - Description string `json:"description,omitempty"` - Dhcpprovider string `json:"dhcpprovider,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Dns1 string `json:"dns1,omitempty"` - Dns2 string `json:"dns2,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Domainname string `json:"domainname,omitempty"` - Guestcidraddress string `json:"guestcidraddress,omitempty"` - Id string `json:"id,omitempty"` - Internaldns1 string `json:"internaldns1,omitempty"` - Internaldns2 string `json:"internaldns2,omitempty"` - Ip6dns1 string `json:"ip6dns1,omitempty"` - Ip6dns2 string `json:"ip6dns2,omitempty"` - Localstorageenabled bool `json:"localstorageenabled,omitempty"` - Name string `json:"name,omitempty"` - Networktype string `json:"networktype,omitempty"` - Resourcedetails map[string]string `json:"resourcedetails,omitempty"` - Securitygroupsenabled bool `json:"securitygroupsenabled,omitempty"` - Tags []struct { - Account string `json:"account,omitempty"` - Customer string `json:"customer,omitempty"` - Domain string `json:"domain,omitempty"` - Domainid string `json:"domainid,omitempty"` - Key string `json:"key,omitempty"` - Project string `json:"project,omitempty"` - Projectid string `json:"projectid,omitempty"` - Resourceid string `json:"resourceid,omitempty"` - Resourcetype string `json:"resourcetype,omitempty"` - Value string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Zonetoken string `json:"zonetoken,omitempty"` -} - -type DedicateZoneParams struct { - p map[string]interface{} -} - -func (p *DedicateZoneParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *DedicateZoneParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *DedicateZoneParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *DedicateZoneParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new DedicateZoneParams instance, -// as then you are sure you have configured all required params -func (s *ZoneService) NewDedicateZoneParams(domainid string, zoneid string) *DedicateZoneParams { - p := &DedicateZoneParams{} - p.p = make(map[string]interface{}) - p.p["domainid"] = domainid - p.p["zoneid"] = zoneid - return p -} - -// Dedicates a zones. -func (s *ZoneService) DedicateZone(p *DedicateZoneParams) (*DedicateZoneResponse, error) { - resp, err := s.cs.newRequest("dedicateZone", p.toURLValues()) - if err != nil { - return nil, err - } - - var r DedicateZoneResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type DedicateZoneResponse struct { - JobID string `json:"jobid,omitempty"` - Accountid string `json:"accountid,omitempty"` - Affinitygroupid string `json:"affinitygroupid,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} - -type ReleaseDedicatedZoneParams struct { - p map[string]interface{} -} - -func (p *ReleaseDedicatedZoneParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ReleaseDedicatedZoneParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ReleaseDedicatedZoneParams instance, -// as then you are sure you have configured all required params -func (s *ZoneService) NewReleaseDedicatedZoneParams(zoneid string) *ReleaseDedicatedZoneParams { - p := &ReleaseDedicatedZoneParams{} - p.p = make(map[string]interface{}) - p.p["zoneid"] = zoneid - return p -} - -// Release dedication of zone -func (s *ZoneService) ReleaseDedicatedZone(p *ReleaseDedicatedZoneParams) (*ReleaseDedicatedZoneResponse, error) { - resp, err := s.cs.newRequest("releaseDedicatedZone", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ReleaseDedicatedZoneResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - - // If we have a async client, we need to wait for the async result - if s.cs.async { - b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) - if err != nil { - if err == AsyncTimeoutErr { - return &r, err - } - return nil, err - } - - if err := json.Unmarshal(b, &r); err != nil { - return nil, err - } - } - return &r, nil -} - -type ReleaseDedicatedZoneResponse struct { - JobID string `json:"jobid,omitempty"` - Displaytext string `json:"displaytext,omitempty"` - Success bool `json:"success,omitempty"` -} - -type ListDedicatedZonesParams struct { - p map[string]interface{} -} - -func (p *ListDedicatedZonesParams) toURLValues() url.Values { - u := url.Values{} - if p.p == nil { - return u - } - if v, found := p.p["account"]; found { - u.Set("account", v.(string)) - } - if v, found := p.p["affinitygroupid"]; found { - u.Set("affinitygroupid", v.(string)) - } - if v, found := p.p["domainid"]; found { - u.Set("domainid", v.(string)) - } - if v, found := p.p["keyword"]; found { - u.Set("keyword", v.(string)) - } - if v, found := p.p["page"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("page", vv) - } - if v, found := p.p["pagesize"]; found { - vv := strconv.Itoa(v.(int)) - u.Set("pagesize", vv) - } - if v, found := p.p["zoneid"]; found { - u.Set("zoneid", v.(string)) - } - return u -} - -func (p *ListDedicatedZonesParams) SetAccount(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["account"] = v - return -} - -func (p *ListDedicatedZonesParams) SetAffinitygroupid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["affinitygroupid"] = v - return -} - -func (p *ListDedicatedZonesParams) SetDomainid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["domainid"] = v - return -} - -func (p *ListDedicatedZonesParams) SetKeyword(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["keyword"] = v - return -} - -func (p *ListDedicatedZonesParams) SetPage(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["page"] = v - return -} - -func (p *ListDedicatedZonesParams) SetPagesize(v int) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["pagesize"] = v - return -} - -func (p *ListDedicatedZonesParams) SetZoneid(v string) { - if p.p == nil { - p.p = make(map[string]interface{}) - } - p.p["zoneid"] = v - return -} - -// You should always use this function to get a new ListDedicatedZonesParams instance, -// as then you are sure you have configured all required params -func (s *ZoneService) NewListDedicatedZonesParams() *ListDedicatedZonesParams { - p := &ListDedicatedZonesParams{} - p.p = make(map[string]interface{}) - return p -} - -// List dedicated zones. -func (s *ZoneService) ListDedicatedZones(p *ListDedicatedZonesParams) (*ListDedicatedZonesResponse, error) { - resp, err := s.cs.newRequest("listDedicatedZones", p.toURLValues()) - if err != nil { - return nil, err - } - - var r ListDedicatedZonesResponse - if err := json.Unmarshal(resp, &r); err != nil { - return nil, err - } - return &r, nil -} - -type ListDedicatedZonesResponse struct { - Count int `json:"count"` - DedicatedZones []*DedicatedZone `json:"dedicatedzone"` -} - -type DedicatedZone struct { - Accountid string `json:"accountid,omitempty"` - Affinitygroupid string `json:"affinitygroupid,omitempty"` - Domainid string `json:"domainid,omitempty"` - Id string `json:"id,omitempty"` - Zoneid string `json:"zoneid,omitempty"` - Zonename string `json:"zonename,omitempty"` -} diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/cloudstack.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/cloudstack.go deleted file mode 100644 index fd1b8d71e79..00000000000 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/cloudstack.go +++ /dev/null @@ -1,936 +0,0 @@ -// -// Copyright 2016, Sander van Harmelen -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package cloudstack - -import ( - "bytes" - "crypto/hmac" - "crypto/sha1" - "crypto/tls" - "encoding/base64" - "encoding/json" - "errors" - "fmt" - "io/ioutil" - "net/http" - "net/url" - "regexp" - "sort" - "strings" - "time" -) - -// UnlimitedResourceID is a special ID to define an unlimited resource -const UnlimitedResourceID = "-1" - -var idRegex = regexp.MustCompile(`^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|-1)$`) - -// IsID return true if the passed ID is either a UUID or a UnlimitedResourceID -func IsID(id string) bool { - return idRegex.MatchString(id) -} - -// OptionFunc can be passed to the courtesy helper functions to set additional parameters -type OptionFunc func(*CloudStackClient, interface{}) error - -type CSError struct { - ErrorCode int `json:"errorcode"` - CSErrorCode int `json:"cserrorcode"` - ErrorText string `json:"errortext"` -} - -func (e *CSError) Error() error { - return fmt.Errorf("CloudStack API error %d (CSExceptionErrorCode: %d): %s", e.ErrorCode, e.CSErrorCode, e.ErrorText) -} - -type CloudStackClient struct { - HTTPGETOnly bool // If `true` only use HTTP GET calls - - client *http.Client // The http client for communicating - baseURL string // The base URL of the API - apiKey string // Api key - secret string // Secret key - async bool // Wait for async calls to finish - timeout int64 // Max waiting timeout in seconds for async jobs to finish; defaults to 300 seconds - - APIDiscovery *APIDiscoveryService - Account *AccountService - Address *AddressService - AffinityGroup *AffinityGroupService - Alert *AlertService - Asyncjob *AsyncjobService - Authentication *AuthenticationService - AutoScale *AutoScaleService - Baremetal *BaremetalService - Certificate *CertificateService - CloudIdentifier *CloudIdentifierService - Cluster *ClusterService - Configuration *ConfigurationService - DiskOffering *DiskOfferingService - Domain *DomainService - Event *EventService - Firewall *FirewallService - GuestOS *GuestOSService - Host *HostService - Hypervisor *HypervisorService - ISO *ISOService - ImageStore *ImageStoreService - InternalLB *InternalLBService - LDAP *LDAPService - Limit *LimitService - LoadBalancer *LoadBalancerService - NAT *NATService - NetworkACL *NetworkACLService - NetworkDevice *NetworkDeviceService - NetworkOffering *NetworkOfferingService - Network *NetworkService - Nic *NicService - NiciraNVP *NiciraNVPService - OvsElement *OvsElementService - Pod *PodService - Pool *PoolService - PortableIP *PortableIPService - Project *ProjectService - Quota *QuotaService - Region *RegionService - Resourcemetadata *ResourcemetadataService - Resourcetags *ResourcetagsService - Router *RouterService - SSH *SSHService - SecurityGroup *SecurityGroupService - ServiceOffering *ServiceOfferingService - Snapshot *SnapshotService - StoragePool *StoragePoolService - StratosphereSSP *StratosphereSSPService - Swift *SwiftService - SystemCapacity *SystemCapacityService - SystemVM *SystemVMService - Template *TemplateService - UCS *UCSService - Usage *UsageService - User *UserService - VLAN *VLANService - VMGroup *VMGroupService - VPC *VPCService - VPN *VPNService - VirtualMachine *VirtualMachineService - Volume *VolumeService - Zone *ZoneService -} - -// Creates a new client for communicating with CloudStack -func newClient(apiurl string, apikey string, secret string, async bool, verifyssl bool) *CloudStackClient { - cs := &CloudStackClient{ - client: &http.Client{ - Transport: &http.Transport{ - Proxy: http.ProxyFromEnvironment, - TLSClientConfig: &tls.Config{InsecureSkipVerify: !verifyssl}, // If verifyssl is true, skipping the verify should be false and vice versa - }, - Timeout: time.Duration(60 * time.Second), - }, - baseURL: apiurl, - apiKey: apikey, - secret: secret, - async: async, - timeout: 300, - } - cs.APIDiscovery = NewAPIDiscoveryService(cs) - cs.Account = NewAccountService(cs) - cs.Address = NewAddressService(cs) - cs.AffinityGroup = NewAffinityGroupService(cs) - cs.Alert = NewAlertService(cs) - cs.Asyncjob = NewAsyncjobService(cs) - cs.Authentication = NewAuthenticationService(cs) - cs.AutoScale = NewAutoScaleService(cs) - cs.Baremetal = NewBaremetalService(cs) - cs.Certificate = NewCertificateService(cs) - cs.CloudIdentifier = NewCloudIdentifierService(cs) - cs.Cluster = NewClusterService(cs) - cs.Configuration = NewConfigurationService(cs) - cs.DiskOffering = NewDiskOfferingService(cs) - cs.Domain = NewDomainService(cs) - cs.Event = NewEventService(cs) - cs.Firewall = NewFirewallService(cs) - cs.GuestOS = NewGuestOSService(cs) - cs.Host = NewHostService(cs) - cs.Hypervisor = NewHypervisorService(cs) - cs.ISO = NewISOService(cs) - cs.ImageStore = NewImageStoreService(cs) - cs.InternalLB = NewInternalLBService(cs) - cs.LDAP = NewLDAPService(cs) - cs.Limit = NewLimitService(cs) - cs.LoadBalancer = NewLoadBalancerService(cs) - cs.NAT = NewNATService(cs) - cs.NetworkACL = NewNetworkACLService(cs) - cs.NetworkDevice = NewNetworkDeviceService(cs) - cs.NetworkOffering = NewNetworkOfferingService(cs) - cs.Network = NewNetworkService(cs) - cs.Nic = NewNicService(cs) - cs.NiciraNVP = NewNiciraNVPService(cs) - cs.OvsElement = NewOvsElementService(cs) - cs.Pod = NewPodService(cs) - cs.Pool = NewPoolService(cs) - cs.PortableIP = NewPortableIPService(cs) - cs.Project = NewProjectService(cs) - cs.Quota = NewQuotaService(cs) - cs.Region = NewRegionService(cs) - cs.Resourcemetadata = NewResourcemetadataService(cs) - cs.Resourcetags = NewResourcetagsService(cs) - cs.Router = NewRouterService(cs) - cs.SSH = NewSSHService(cs) - cs.SecurityGroup = NewSecurityGroupService(cs) - cs.ServiceOffering = NewServiceOfferingService(cs) - cs.Snapshot = NewSnapshotService(cs) - cs.StoragePool = NewStoragePoolService(cs) - cs.StratosphereSSP = NewStratosphereSSPService(cs) - cs.Swift = NewSwiftService(cs) - cs.SystemCapacity = NewSystemCapacityService(cs) - cs.SystemVM = NewSystemVMService(cs) - cs.Template = NewTemplateService(cs) - cs.UCS = NewUCSService(cs) - cs.Usage = NewUsageService(cs) - cs.User = NewUserService(cs) - cs.VLAN = NewVLANService(cs) - cs.VMGroup = NewVMGroupService(cs) - cs.VPC = NewVPCService(cs) - cs.VPN = NewVPNService(cs) - cs.VirtualMachine = NewVirtualMachineService(cs) - cs.Volume = NewVolumeService(cs) - cs.Zone = NewZoneService(cs) - return cs -} - -// Default non-async client. So for async calls you need to implement and check the async job result yourself. When using -// HTTPS with a self-signed certificate to connect to your CloudStack API, you would probably want to set 'verifyssl' to -// false so the call ignores the SSL errors/warnings. -func NewClient(apiurl string, apikey string, secret string, verifyssl bool) *CloudStackClient { - cs := newClient(apiurl, apikey, secret, false, verifyssl) - return cs -} - -// For sync API calls this client behaves exactly the same as a standard client call, but for async API calls -// this client will wait until the async job is finished or until the configured AsyncTimeout is reached. When the async -// job finishes successfully it will return actual object received from the API and nil, but when the timout is -// reached it will return the initial object containing the async job ID for the running job and a warning. -func NewAsyncClient(apiurl string, apikey string, secret string, verifyssl bool) *CloudStackClient { - cs := newClient(apiurl, apikey, secret, true, verifyssl) - return cs -} - -// When using the async client an api call will wait for the async call to finish before returning. The default is to poll for 300 seconds -// seconds, to check if the async job is finished. -func (cs *CloudStackClient) AsyncTimeout(timeoutInSeconds int64) { - cs.timeout = timeoutInSeconds -} - -var AsyncTimeoutErr = errors.New("Timeout while waiting for async job to finish") - -// A helper function that you can use to get the result of a running async job. If the job is not finished within the configured -// timeout, the async job returns a AsyncTimeoutErr. -func (cs *CloudStackClient) GetAsyncJobResult(jobid string, timeout int64) (json.RawMessage, error) { - var timer time.Duration - currentTime := time.Now().Unix() - - for { - p := cs.Asyncjob.NewQueryAsyncJobResultParams(jobid) - r, err := cs.Asyncjob.QueryAsyncJobResult(p) - if err != nil { - return nil, err - } - - // Status 1 means the job is finished successfully - if r.Jobstatus == 1 { - return r.Jobresult, nil - } - - // When the status is 2, the job has failed - if r.Jobstatus == 2 { - if r.Jobresulttype == "text" { - return nil, fmt.Errorf(string(r.Jobresult)) - } else { - return nil, fmt.Errorf("Undefined error: %s", string(r.Jobresult)) - } - } - - if time.Now().Unix()-currentTime > timeout { - return nil, AsyncTimeoutErr - } - - // Add an (extremely simple) exponential backoff like feature to prevent - // flooding the CloudStack API - if timer < 15 { - timer++ - } - - time.Sleep(timer * time.Second) - } -} - -// Execute the request against a CS API. Will return the raw JSON data returned by the API and nil if -// no error occured. If the API returns an error the result will be nil and the HTTP error code and CS -// error details. If a processing (code) error occurs the result will be nil and the generated error -func (cs *CloudStackClient) newRequest(api string, params url.Values) (json.RawMessage, error) { - params.Set("apiKey", cs.apiKey) - params.Set("command", api) - params.Set("response", "json") - - // Generate signature for API call - // * Serialize parameters, URL encoding only values and sort them by key, done by encodeValues - // * Convert the entire argument string to lowercase - // * Replace all instances of '+' to '%20' - // * Calculate HMAC SHA1 of argument string with CloudStack secret - // * URL encode the string and convert to base64 - s := encodeValues(params) - s2 := strings.ToLower(s) - s3 := strings.Replace(s2, "+", "%20", -1) - mac := hmac.New(sha1.New, []byte(cs.secret)) - mac.Write([]byte(s3)) - signature := base64.StdEncoding.EncodeToString(mac.Sum(nil)) - - var err error - var resp *http.Response - if !cs.HTTPGETOnly && (api == "deployVirtualMachine" || api == "updateVirtualMachine") { - // The deployVirtualMachine API should be called using a POST call - // so we don't have to worry about the userdata size - - // Add the unescaped signature to the POST params - params.Set("signature", signature) - - // Make a POST call - resp, err = cs.client.PostForm(cs.baseURL, params) - } else { - // Create the final URL before we issue the request - url := cs.baseURL + "?" + s + "&signature=" + url.QueryEscape(signature) - - // Make a GET call - resp, err = cs.client.Get(url) - } - if err != nil { - return nil, err - } - defer resp.Body.Close() - - b, err := ioutil.ReadAll(resp.Body) - if err != nil { - return nil, err - } - - // Need to get the raw value to make the result play nice - b, err = getRawValue(b) - if err != nil { - return nil, err - } - - if resp.StatusCode != 200 { - var e CSError - if err := json.Unmarshal(b, &e); err != nil { - return nil, err - } - return nil, e.Error() - } - return b, nil -} - -// Custom version of net/url Encode that only URL escapes values -// Unmodified portions here remain under BSD license of The Go Authors: https://go.googlesource.com/go/+/master/LICENSE -func encodeValues(v url.Values) string { - if v == nil { - return "" - } - var buf bytes.Buffer - keys := make([]string, 0, len(v)) - for k := range v { - keys = append(keys, k) - } - sort.Strings(keys) - for _, k := range keys { - vs := v[k] - prefix := k + "=" - for _, v := range vs { - if buf.Len() > 0 { - buf.WriteByte('&') - } - buf.WriteString(prefix) - buf.WriteString(url.QueryEscape(v)) - } - } - return buf.String() -} - -// Generic function to get the first raw value from a response as json.RawMessage -func getRawValue(b json.RawMessage) (json.RawMessage, error) { - var m map[string]json.RawMessage - if err := json.Unmarshal(b, &m); err != nil { - return nil, err - } - for _, v := range m { - return v, nil - } - return nil, fmt.Errorf("Unable to extract the raw value from:\n\n%s\n\n", string(b)) -} - -// ProjectIDSetter is an interface that every type that can set a project ID must implement -type ProjectIDSetter interface { - SetProjectid(string) -} - -// WithProject takes either a project name or ID and sets the `projectid` parameter -func WithProject(project string) OptionFunc { - return func(cs *CloudStackClient, p interface{}) error { - ps, ok := p.(ProjectIDSetter) - - if !ok || project == "" { - return nil - } - - if !IsID(project) { - id, _, err := cs.Project.GetProjectID(project) - if err != nil { - return err - } - project = id - } - - ps.SetProjectid(project) - - return nil - } -} - -// VPCIDSetter is an interface that every type that can set a vpc ID must implement -type VPCIDSetter interface { - SetVpcid(string) -} - -// WithVPCID takes a vpc ID and sets the `vpcid` parameter -func WithVPCID(id string) OptionFunc { - return func(cs *CloudStackClient, p interface{}) error { - vs, ok := p.(VPCIDSetter) - - if !ok || id == "" { - return nil - } - - vs.SetVpcid(id) - - return nil - } -} - -type APIDiscoveryService struct { - cs *CloudStackClient -} - -func NewAPIDiscoveryService(cs *CloudStackClient) *APIDiscoveryService { - return &APIDiscoveryService{cs: cs} -} - -type AccountService struct { - cs *CloudStackClient -} - -func NewAccountService(cs *CloudStackClient) *AccountService { - return &AccountService{cs: cs} -} - -type AddressService struct { - cs *CloudStackClient -} - -func NewAddressService(cs *CloudStackClient) *AddressService { - return &AddressService{cs: cs} -} - -type AffinityGroupService struct { - cs *CloudStackClient -} - -func NewAffinityGroupService(cs *CloudStackClient) *AffinityGroupService { - return &AffinityGroupService{cs: cs} -} - -type AlertService struct { - cs *CloudStackClient -} - -func NewAlertService(cs *CloudStackClient) *AlertService { - return &AlertService{cs: cs} -} - -type AsyncjobService struct { - cs *CloudStackClient -} - -func NewAsyncjobService(cs *CloudStackClient) *AsyncjobService { - return &AsyncjobService{cs: cs} -} - -type AuthenticationService struct { - cs *CloudStackClient -} - -func NewAuthenticationService(cs *CloudStackClient) *AuthenticationService { - return &AuthenticationService{cs: cs} -} - -type AutoScaleService struct { - cs *CloudStackClient -} - -func NewAutoScaleService(cs *CloudStackClient) *AutoScaleService { - return &AutoScaleService{cs: cs} -} - -type BaremetalService struct { - cs *CloudStackClient -} - -func NewBaremetalService(cs *CloudStackClient) *BaremetalService { - return &BaremetalService{cs: cs} -} - -type CertificateService struct { - cs *CloudStackClient -} - -func NewCertificateService(cs *CloudStackClient) *CertificateService { - return &CertificateService{cs: cs} -} - -type CloudIdentifierService struct { - cs *CloudStackClient -} - -func NewCloudIdentifierService(cs *CloudStackClient) *CloudIdentifierService { - return &CloudIdentifierService{cs: cs} -} - -type ClusterService struct { - cs *CloudStackClient -} - -func NewClusterService(cs *CloudStackClient) *ClusterService { - return &ClusterService{cs: cs} -} - -type ConfigurationService struct { - cs *CloudStackClient -} - -func NewConfigurationService(cs *CloudStackClient) *ConfigurationService { - return &ConfigurationService{cs: cs} -} - -type DiskOfferingService struct { - cs *CloudStackClient -} - -func NewDiskOfferingService(cs *CloudStackClient) *DiskOfferingService { - return &DiskOfferingService{cs: cs} -} - -type DomainService struct { - cs *CloudStackClient -} - -func NewDomainService(cs *CloudStackClient) *DomainService { - return &DomainService{cs: cs} -} - -type EventService struct { - cs *CloudStackClient -} - -func NewEventService(cs *CloudStackClient) *EventService { - return &EventService{cs: cs} -} - -type FirewallService struct { - cs *CloudStackClient -} - -func NewFirewallService(cs *CloudStackClient) *FirewallService { - return &FirewallService{cs: cs} -} - -type GuestOSService struct { - cs *CloudStackClient -} - -func NewGuestOSService(cs *CloudStackClient) *GuestOSService { - return &GuestOSService{cs: cs} -} - -type HostService struct { - cs *CloudStackClient -} - -func NewHostService(cs *CloudStackClient) *HostService { - return &HostService{cs: cs} -} - -type HypervisorService struct { - cs *CloudStackClient -} - -func NewHypervisorService(cs *CloudStackClient) *HypervisorService { - return &HypervisorService{cs: cs} -} - -type ISOService struct { - cs *CloudStackClient -} - -func NewISOService(cs *CloudStackClient) *ISOService { - return &ISOService{cs: cs} -} - -type ImageStoreService struct { - cs *CloudStackClient -} - -func NewImageStoreService(cs *CloudStackClient) *ImageStoreService { - return &ImageStoreService{cs: cs} -} - -type InternalLBService struct { - cs *CloudStackClient -} - -func NewInternalLBService(cs *CloudStackClient) *InternalLBService { - return &InternalLBService{cs: cs} -} - -type LDAPService struct { - cs *CloudStackClient -} - -func NewLDAPService(cs *CloudStackClient) *LDAPService { - return &LDAPService{cs: cs} -} - -type LimitService struct { - cs *CloudStackClient -} - -func NewLimitService(cs *CloudStackClient) *LimitService { - return &LimitService{cs: cs} -} - -type LoadBalancerService struct { - cs *CloudStackClient -} - -func NewLoadBalancerService(cs *CloudStackClient) *LoadBalancerService { - return &LoadBalancerService{cs: cs} -} - -type NATService struct { - cs *CloudStackClient -} - -func NewNATService(cs *CloudStackClient) *NATService { - return &NATService{cs: cs} -} - -type NetworkACLService struct { - cs *CloudStackClient -} - -func NewNetworkACLService(cs *CloudStackClient) *NetworkACLService { - return &NetworkACLService{cs: cs} -} - -type NetworkDeviceService struct { - cs *CloudStackClient -} - -func NewNetworkDeviceService(cs *CloudStackClient) *NetworkDeviceService { - return &NetworkDeviceService{cs: cs} -} - -type NetworkOfferingService struct { - cs *CloudStackClient -} - -func NewNetworkOfferingService(cs *CloudStackClient) *NetworkOfferingService { - return &NetworkOfferingService{cs: cs} -} - -type NetworkService struct { - cs *CloudStackClient -} - -func NewNetworkService(cs *CloudStackClient) *NetworkService { - return &NetworkService{cs: cs} -} - -type NicService struct { - cs *CloudStackClient -} - -func NewNicService(cs *CloudStackClient) *NicService { - return &NicService{cs: cs} -} - -type NiciraNVPService struct { - cs *CloudStackClient -} - -func NewNiciraNVPService(cs *CloudStackClient) *NiciraNVPService { - return &NiciraNVPService{cs: cs} -} - -type OvsElementService struct { - cs *CloudStackClient -} - -func NewOvsElementService(cs *CloudStackClient) *OvsElementService { - return &OvsElementService{cs: cs} -} - -type PodService struct { - cs *CloudStackClient -} - -func NewPodService(cs *CloudStackClient) *PodService { - return &PodService{cs: cs} -} - -type PoolService struct { - cs *CloudStackClient -} - -func NewPoolService(cs *CloudStackClient) *PoolService { - return &PoolService{cs: cs} -} - -type PortableIPService struct { - cs *CloudStackClient -} - -func NewPortableIPService(cs *CloudStackClient) *PortableIPService { - return &PortableIPService{cs: cs} -} - -type ProjectService struct { - cs *CloudStackClient -} - -func NewProjectService(cs *CloudStackClient) *ProjectService { - return &ProjectService{cs: cs} -} - -type QuotaService struct { - cs *CloudStackClient -} - -func NewQuotaService(cs *CloudStackClient) *QuotaService { - return &QuotaService{cs: cs} -} - -type RegionService struct { - cs *CloudStackClient -} - -func NewRegionService(cs *CloudStackClient) *RegionService { - return &RegionService{cs: cs} -} - -type ResourcemetadataService struct { - cs *CloudStackClient -} - -func NewResourcemetadataService(cs *CloudStackClient) *ResourcemetadataService { - return &ResourcemetadataService{cs: cs} -} - -type ResourcetagsService struct { - cs *CloudStackClient -} - -func NewResourcetagsService(cs *CloudStackClient) *ResourcetagsService { - return &ResourcetagsService{cs: cs} -} - -type RouterService struct { - cs *CloudStackClient -} - -func NewRouterService(cs *CloudStackClient) *RouterService { - return &RouterService{cs: cs} -} - -type SSHService struct { - cs *CloudStackClient -} - -func NewSSHService(cs *CloudStackClient) *SSHService { - return &SSHService{cs: cs} -} - -type SecurityGroupService struct { - cs *CloudStackClient -} - -func NewSecurityGroupService(cs *CloudStackClient) *SecurityGroupService { - return &SecurityGroupService{cs: cs} -} - -type ServiceOfferingService struct { - cs *CloudStackClient -} - -func NewServiceOfferingService(cs *CloudStackClient) *ServiceOfferingService { - return &ServiceOfferingService{cs: cs} -} - -type SnapshotService struct { - cs *CloudStackClient -} - -func NewSnapshotService(cs *CloudStackClient) *SnapshotService { - return &SnapshotService{cs: cs} -} - -type StoragePoolService struct { - cs *CloudStackClient -} - -func NewStoragePoolService(cs *CloudStackClient) *StoragePoolService { - return &StoragePoolService{cs: cs} -} - -type StratosphereSSPService struct { - cs *CloudStackClient -} - -func NewStratosphereSSPService(cs *CloudStackClient) *StratosphereSSPService { - return &StratosphereSSPService{cs: cs} -} - -type SwiftService struct { - cs *CloudStackClient -} - -func NewSwiftService(cs *CloudStackClient) *SwiftService { - return &SwiftService{cs: cs} -} - -type SystemCapacityService struct { - cs *CloudStackClient -} - -func NewSystemCapacityService(cs *CloudStackClient) *SystemCapacityService { - return &SystemCapacityService{cs: cs} -} - -type SystemVMService struct { - cs *CloudStackClient -} - -func NewSystemVMService(cs *CloudStackClient) *SystemVMService { - return &SystemVMService{cs: cs} -} - -type TemplateService struct { - cs *CloudStackClient -} - -func NewTemplateService(cs *CloudStackClient) *TemplateService { - return &TemplateService{cs: cs} -} - -type UCSService struct { - cs *CloudStackClient -} - -func NewUCSService(cs *CloudStackClient) *UCSService { - return &UCSService{cs: cs} -} - -type UsageService struct { - cs *CloudStackClient -} - -func NewUsageService(cs *CloudStackClient) *UsageService { - return &UsageService{cs: cs} -} - -type UserService struct { - cs *CloudStackClient -} - -func NewUserService(cs *CloudStackClient) *UserService { - return &UserService{cs: cs} -} - -type VLANService struct { - cs *CloudStackClient -} - -func NewVLANService(cs *CloudStackClient) *VLANService { - return &VLANService{cs: cs} -} - -type VMGroupService struct { - cs *CloudStackClient -} - -func NewVMGroupService(cs *CloudStackClient) *VMGroupService { - return &VMGroupService{cs: cs} -} - -type VPCService struct { - cs *CloudStackClient -} - -func NewVPCService(cs *CloudStackClient) *VPCService { - return &VPCService{cs: cs} -} - -type VPNService struct { - cs *CloudStackClient -} - -func NewVPNService(cs *CloudStackClient) *VPNService { - return &VPNService{cs: cs} -} - -type VirtualMachineService struct { - cs *CloudStackClient -} - -func NewVirtualMachineService(cs *CloudStackClient) *VirtualMachineService { - return &VirtualMachineService{cs: cs} -} - -type VolumeService struct { - cs *CloudStackClient -} - -func NewVolumeService(cs *CloudStackClient) *VolumeService { - return &VolumeService{cs: cs} -} - -type ZoneService struct { - cs *CloudStackClient -} - -func NewZoneService(cs *CloudStackClient) *ZoneService { - return &ZoneService{cs: cs} -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 48c9758c808..f143460cf8a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -273,10 +273,6 @@ github.com/coreos/pkg/dlopen github.com/cpuguy83/go-md2man/md2man # github.com/cyphar/filepath-securejoin v0.0.0-20170720062807-ae69057f2299 => github.com/cyphar/filepath-securejoin v0.0.0-20170720062807-ae69057f2299 github.com/cyphar/filepath-securejoin -# github.com/d2g/dhcp4 v0.0.0-20170904100407-a1d1b6c41b1c => github.com/d2g/dhcp4 v0.0.0-20170904100407-a1d1b6c41b1c -github.com/d2g/dhcp4 -# github.com/d2g/dhcp4client v0.0.0-20170829104524-6e570ed0a266 => github.com/d2g/dhcp4client v0.0.0-20170829104524-6e570ed0a266 -github.com/d2g/dhcp4client # github.com/davecgh/go-spew v1.1.1 => github.com/davecgh/go-spew v1.1.1 github.com/davecgh/go-spew/spew # github.com/daviddengcn/go-colortext v0.0.0-20160507010035-511bcaf42ccd => github.com/daviddengcn/go-colortext v0.0.0-20160507010035-511bcaf42ccd @@ -812,12 +808,6 @@ github.com/vmware/govmomi/vim25/progress github.com/vmware/govmomi/vim25/soap github.com/vmware/govmomi/vim25/types github.com/vmware/govmomi/vim25/xml -# github.com/vmware/photon-controller-go-sdk v0.0.0-20170310013346-4a435daef6cc => github.com/vmware/photon-controller-go-sdk v0.0.0-20170310013346-4a435daef6cc -github.com/vmware/photon-controller-go-sdk/SSPI -github.com/vmware/photon-controller-go-sdk/photon -github.com/vmware/photon-controller-go-sdk/photon/lightwave -# github.com/xanzy/go-cloudstack v0.0.0-20160728180336-1e2cbf647e57 => github.com/xanzy/go-cloudstack v0.0.0-20160728180336-1e2cbf647e57 -github.com/xanzy/go-cloudstack/cloudstack # github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18 => github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18 github.com/xiang90/probing # go.uber.org/atomic v0.0.0-20181018215023-8dc6146f7569 => go.uber.org/atomic v0.0.0-20181018215023-8dc6146f7569