citrix-daas-rest-go

module
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2024 License: Apache-2.0

README

Client for Go for use with Citrix services

About

The Client for Go for use with Citrix DaaS™ APIs enables managing Citrix DaaS resources programmatically in applications written in the Go programming language.

Installation

  • From GitHub
go get github.com/citrix/citrix-daas-rest-go
  • Enable optional remote PoSH on the storefront server
Enable-PSRemoting -Force

Usage

The Client for Go for use with Citrix DaaS APIs contains the following five packages::

  1. github.com/citrix/citrix-daas-rest-go/citrixorchestration: SDK which contains the client model and api functions for Citrix DaaS API. This is auto-generated by OpenAPI Generator and do not require any manual changes.
  2. github.com/citrix/citrix-daas-rest-go/client: Rest client configurable with Citrix DaaS customer details and handles authentication.
  3. github.com/citrix/citrix-daas-rest-go/citrixstorefront: SDK which contains the client model and PowerShell SDK functions for Citrix StoreFront Server. This interacts with PowerShell on the StoreFront server either locally or via Remote PowerShell.
  4. github.com/citrix/citrix-daas-rest-go/ccresourcelocations: SDK which contains the client model and api functions for Citrix Resource Locations API. This is auto-generated by OpenAPI Generator and do not require any manual changes.
  5. github.com/citrix/citrix-daas-rest-go/globalappconfiguration: SDK which contains the client model and api functions for Citrix Global App Configuration Service API. This is auto-generated by OpenAPI Generator and do not require any manual changes.

Instantiate a client using NewCitrixDaasClient. The following variables are required to configure Citrix DaaS client:

Cloud On-Premises
authUrl Citrix Cloud authentication URL, i.e. https://api-us.cloud.com/cctrustoauth2/{customerId}/tokens/clients for US customers. On-Premises trust service URL, i.e. https://{deliveryControllerHostname}/citrix/orchestration/api/techpreview/tokens
hostname Citrix Cloud DaaS service hostname, i.e. {customerId}.xendesktop.net Delivery Controller Hostname / IP address
customerId Cloud Customer Id CitrixOnPremises
clientId Citrix Cloud API Key clientId Domain Admin Username
clientSecret Citrix Cloud API Key clientSecret Domain Admin Password
onPremise false true
ccUrl Citrix Cloud URL, i.e. https://api.cloud.com Not Supported

Example

package main

import (
        "context"
        citrixstorefront "github.com/citrix/citrix-daas-rest-go/citrixstorefront/models"
        citrixorchestration "github.com/citrix/citrix-daas-rest-go/citrixorchestration"
        citrixclient "github.com/citrix/citrix-daas-rest-go/client"
)

func main() {
        // Create a new Citrix API client for cloud customer 83czxoqlpepv
        authUrl := "https://api-us.cloud.com/cctrustoauth2/83czxoqlpepv/tokens/clients"
        hostname := "83czxoqlpepv.xendesktop.net"
        customerId := "83czxoqlpepv"
        clientId := "{apiKeyClientId}"
        clientSecret := "{apiKeyClientSecret}"
        onPremise := false
        ccUrl := https://api.cloud.com
        client, err := citrixclient.NewCitrixDaasClient(authUrl, ccUrl, hostname, customerId, clientId, clientSecret, onPremise, nil, nil)
        
        // Optional configuration for storefront client
        computerName := "{Storefront Server FQDN}"
        sfadUserName := "{AD username}"
        sfadUserPass := "{AD password}"
        sfclient, err :=  citrixclient.NewStoreFrontClient(computerName, sfadUserName, sfadUserPass, client)

        /************* citrixorchestration client example *************/
        // Create GET zone request with zoneId and siteId
        zoneId := "8994379b-8585-4717-9765-632992e738d3"
        siteId := "8509b2e6-ff02-48bb-aaa3-07b84f09b9f4"
        getZoneRequest := client.ApiClient.ZonesTPApi.ZonesTPGetZone(ctx, zoneId, customerId, siteId)

        // Get bearer token and put into authorization header
        token, _ := client.SignIn()
        getZoneRequest = getZoneRequest.Authorization(token)

        // Execute request and get response
        zone, _, err := getZoneRequest.Execute()
        if err != nil {
            return
        }

        /************* citrixstorefront client example *************/
        var body citrixstorefront.CreateSTFDeploymentRequestModel
        createDeploymentRequest := client.StorefrontClient.DeploymentSF.STFDeploymentCreateSTFDeployment(ctx, body)
}

Attributions

The code in this repository makes use of the following packages:

License

This project is 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.

Copyright © 2023. Citrix Systems, Inc.

Directories

Path Synopsis
citrixstorefront

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL