本文整理汇总了Golang中github.com/soundtrackyourbrand/utils/key.Key类的典型用法代码示例。如果您正苦于以下问题:Golang Key类的具体用法?Golang Key怎么用?Golang Key使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Key类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: ToGAE
func ToGAE(c appengine.Context, k key.Key) *datastore.Key {
if len(k) < 1 {
return nil
}
kind, stringID, intID, parent := k.Split()
return datastore.NewKey(c, kind, stringID, intID, ToGAE(c, key.Key(parent)))
}
开发者ID:DaviWei,项目名称:utils-1,代码行数:7,代码来源:gaekey.go
示例2: cacheKeys
// cacheKeys will append to oldKeys, and also return as newKeys, all cache keys this finder may use to find the provided model.
// the reason there may be multiple keys is that we don't know which ancestor will be used when finding the model.
func (self finder) cacheKeys(c PersistenceContext, model interface{}, oldKeys *[]string) (newKeys []string, err error) {
var id key.Key
if _, id, err = getTypeAndId(model); err != nil {
return
}
values := make([]interface{}, len(self.fields))
val := reflect.ValueOf(model).Elem()
for index, field := range self.fields {
values[index] = val.FieldByName(field.Name).Interface()
}
if oldKeys == nil {
oldKeys = &[]string{}
}
for id != "" {
*oldKeys = append(*oldKeys, self.keyForValues(id.Parent(), values))
id = id.Parent()
}
newKeys = *oldKeys
return
}
开发者ID:DaviWei,项目名称:utils-1,代码行数:22,代码来源:finder.go
示例3: UpdateDoc
func UpdateDoc(c ElasticConnector, index string, id key.Key, groovyCode string, params map[string]interface{}) (err error) {
index = processIndexName(index)
url := fmt.Sprintf("%s/%s/%s/%s/_update?retry_on_conflict=%v",
c.GetElasticService(),
index,
id.Kind(),
id.Encode(),
UpdateConflictRetries)
json, err := json.Marshal(UpdateRequest{
Script: groovyCode,
Params: params,
})
if err != nil {
return
}
request, err := http.NewRequest("POST", url, bytes.NewBuffer(json))
if err != nil {
return
}
if c.GetElasticUsername() != "" {
request.SetBasicAuth(c.GetElasticUsername(), c.GetElasticPassword())
}
response, err := c.Client().Do(request)
if err != nil {
return
}
defer response.Body.Close()
if response.StatusCode != http.StatusOK {
body, _ := ioutil.ReadAll(response.Body)
err = errors.Errorf("Bad status code from elasticsearch %v: %v, %v", url, response.Status, string(body))
return
}
return
}
开发者ID:DaviWei,项目名称:utils-1,代码行数:39,代码来源:elasticsearch.go
示例4: GetSpotifyAccount
func GetSpotifyAccount(c ServiceConnector, soundZone key.Key, token AccessToken) (result *RemoteSpotifyAccount, err error) {
request, response, err := DoRequest(c, "GET", c.GetPaymentService(), fmt.Sprintf("sound_zones/%v/spotify_account", soundZone.Encode()), token, nil)
if err != nil {
return
}
if response.StatusCode != 200 {
err = errorFor(request, response)
return
}
result = &RemoteSpotifyAccount{}
err = json.NewDecoder(response.Body).Decode(result)
return
}
开发者ID:DaviWei,项目名称:utils-1,代码行数:14,代码来源:client.go
示例5: GetSoundZones
func GetSoundZones(c ServiceConnector, account_id key.Key, token AccessToken) (result RemoteSoundZones, err error) {
request, response, err := DoRequest(c, "GET", c.GetAuthService(), fmt.Sprintf("accounts/%v/sound_zones", account_id.Encode()), token, nil)
if err != nil {
return
}
if response.StatusCode != 200 {
err = errorFor(request, response)
return
}
result = RemoteSoundZones{}
err = json.NewDecoder(response.Body).Decode(&result)
return
}
开发者ID:DaviWei,项目名称:utils-1,代码行数:14,代码来源:client.go
示例6: CreateBusinessAccount
func CreateBusinessAccount(c ServiceConnector, token AccessToken, account RemoteAccount, owner key.Key) (result *RemoteAccount, err error) {
request, response, err := DoRequest(c, "POST", c.GetAuthService(), fmt.Sprintf("users/%v/accounts/business", owner.Encode()), token, account)
if err != nil {
return
}
if response.StatusCode != 201 {
err = errorFor(request, response)
return
}
result = &RemoteAccount{}
err = json.NewDecoder(response.Body).Decode(result)
return
}
开发者ID:DaviWei,项目名称:utils-1,代码行数:15,代码来源:client.go
示例7: UpdateSoundZoneErrors
func UpdateSoundZoneErrors(c ServiceConnector, token AccessToken, soundZoneId key.Key, soundZoneError RemoteSoundZoneError) (err error) {
request, response, err := DoRequest(c, "POST", c.GetAuthService(), fmt.Sprintf("sound_zones/%v/sound_zone_errors", soundZoneId.Encode()), token, soundZoneError)
if err != nil {
return
}
if response.StatusCode != 200 {
err = errorFor(request, response)
return
}
return
}
开发者ID:DaviWei,项目名称:utils-1,代码行数:12,代码来源:client.go
示例8: GetProductQueue
func GetProductQueue(c ServiceConnector, productQueueId key.Key, token AccessToken) (result *RemoteProductQueue, err error) {
request, response, err := DoRequest(c, "GET", c.GetPaymentService(), fmt.Sprintf("product_queues/%v", productQueueId.Encode()), token, nil)
if err != nil {
return
}
if response.StatusCode != 200 {
err = errorFor(request, response)
return
}
result = &RemoteProductQueue{}
err = json.NewDecoder(response.Body).Decode(result)
return
}
开发者ID:DaviWei,项目名称:utils-1,代码行数:15,代码来源:client.go
示例9: SetPassword
func SetPassword(c ServiceConnector, user key.Key, password string, token AccessToken) (result *RemoteUser, err error) {
request, response, err := DoRequest(c, "PUT", c.GetAuthService(), fmt.Sprintf("users/%s/password", user.Encode()), token, map[string]string{
"password": password,
})
if err != nil {
return
}
if response.StatusCode != 200 {
err = errorFor(request, response)
return
}
result = &RemoteUser{}
err = json.NewDecoder(response.Body).Decode(result)
return
}
开发者ID:DaviWei,项目名称:utils-1,代码行数:17,代码来源:client.go
示例10: GetBillingGroupsByAccountId
func GetBillingGroupsByAccountId(c ServiceConnector, account key.Key, token AccessToken) (result RemoteBillingGroups, err error) {
request, response, err := DoRequest(c, "GET", c.GetPaymentService(), fmt.Sprintf("accounts/%v/billing_groups", account.Encode()), token, nil)
if err != nil {
return
}
if response.StatusCode != 200 {
err = errorFor(request, response)
return
}
result = RemoteBillingGroups{}
err = json.NewDecoder(response.Body).Decode(&result)
return
}
开发者ID:DaviWei,项目名称:utils-1,代码行数:15,代码来源:client.go
示例11: CreateSoundZoneError
func CreateSoundZoneError(c ServiceConnector, token AccessToken, e RemoteSoundZoneError, soundZoneId key.Key) (result *RemoteSoundZoneError, err error) {
request, response, err := DoRequest(c, "POST", c.GetAuthService(), fmt.Sprintf("sound_zones/%v/sound_zone_errors", soundZoneId.Encode()), token, e)
if err != nil {
return
}
if response.StatusCode != 200 {
err = errorFor(request, response)
return
}
result = &RemoteSoundZoneError{}
err = json.NewDecoder(response.Body).Decode(result)
return
}
开发者ID:DaviWei,项目名称:utils-1,代码行数:15,代码来源:client.go
示例12: GetAccountContact
func GetAccountContact(c ServiceConnector, account key.Key, token AccessToken) (result *RemoteUser, err error) {
request, response, err := DoRequest(c, "GET", c.GetAuthService(), fmt.Sprintf("accounts/%v/contact", account.Encode()), token, nil)
if err != nil {
return
}
if response.StatusCode != 200 {
err = errorFor(request, response)
return
}
result = &RemoteUser{}
err = json.NewDecoder(response.Body).Decode(result)
return
}
开发者ID:DaviWei,项目名称:utils-1,代码行数:15,代码来源:client.go
示例13: GetLocation
func GetLocation(c ServiceConnector, location key.Key, token AccessToken) (result *RemoteLocation, err error) {
request, response, err := DoRequest(c, "GET", c.GetAuthService(), fmt.Sprintf("locations/%v", location.Encode()), token, nil)
if err != nil {
return
}
if response.StatusCode != 200 {
err = errorFor(request, response)
return
}
result = &RemoteLocation{}
err = json.NewDecoder(response.Body).Decode(result)
return
}
开发者ID:DaviWei,项目名称:utils-1,代码行数:15,代码来源:client.go
示例14: ReplaceScheduleForSoundZones
func ReplaceScheduleForSoundZones(c ServiceConnector, oldSchedule, newSchedule key.Key, token AccessToken) (err error) {
scheduleRef := &ScheduleRef{
Schedule: newSchedule,
}
request, response, err := DoRequest(c, "PUT", c.GetAuthService(), fmt.Sprintf("schedules/%v/sound_zones", oldSchedule.Encode()), token, scheduleRef)
if err != nil {
return
}
if response.StatusCode != 200 {
err = errorFor(request, response)
return
}
return
}
开发者ID:DaviWei,项目名称:utils-1,代码行数:14,代码来源:client.go
示例15: CountSoundZonesForSchedule
func CountSoundZonesForSchedule(c ServiceConnector, schedule key.Key, token AccessToken) (result int, err error) {
request, response, err := DoRequest(c, "GET", c.GetAuthService(), fmt.Sprintf("schedules/%v/sound_zone_count", schedule.Encode()), token, nil)
if err != nil {
return
}
if response.StatusCode != 200 {
err = errorFor(request, response)
return
}
container := &CountContainer{}
if err = json.NewDecoder(response.Body).Decode(container); err != nil {
return
}
result = container.Count
return
}
开发者ID:DaviWei,项目名称:utils-1,代码行数:19,代码来源:client.go
示例16: GetSpotifyAccounts
func GetSpotifyAccounts(c ServiceConnector, account key.Key, token AccessToken) (result RemoteSpotifyAccounts, err error) {
request, response, err := DoRequest(c, "GET", c.GetPaymentService(), fmt.Sprintf("accounts/%v/payment_method/spotify_accounts", account.Encode()), token, nil)
if err != nil {
return
}
if response.StatusCode != 200 {
err = errorFor(request, response)
return
}
result = RemoteSpotifyAccounts{}
err = json.NewDecoder(response.Body).Decode(&result)
return
}
开发者ID:DaviWei,项目名称:utils-1,代码行数:14,代码来源:client.go
示例17: DeactivateSpotifyAccount
func DeactivateSpotifyAccount(c ServiceConnector, soundZone key.Key, token AccessToken) (err error) {
request, response, err := DoRequest(c, "POST", c.GetPaymentService(), fmt.Sprintf("sound_zones/%v/spotify_account/deactivate", soundZone.Encode()), token, nil)
if err != nil {
return
}
if response.StatusCode != 200 {
err = errorFor(request, response)
return
}
return
}
开发者ID:DaviWei,项目名称:utils-1,代码行数:12,代码来源:client.go
示例18: UpdatePaymentMethodByAccountId
func UpdatePaymentMethodByAccountId(c ServiceConnector, account key.Key, paymentMethod RemotePaymentMethod, token AccessToken) (err error) {
request, response, err := DoRequest(c, "PUT", c.GetPaymentService(), fmt.Sprintf("accounts/%v/payment_method", account.Encode()), token, paymentMethod)
if err != nil {
return
}
if response.StatusCode != 200 {
err = errorFor(request, response)
return
}
return
}
开发者ID:DaviWei,项目名称:utils-1,代码行数:12,代码来源:client.go
示例19: GetDeviceHierarchy
func GetDeviceHierarchy(c ServiceConnector, deviceId key.Key, token AccessToken) (result *DeviceHierarchy, err error) {
request, response, err := DoRequest(c, "GET", c.GetAuthService(), fmt.Sprintf("/device_hierarchy/device/%v", deviceId.Encode()), token, nil)
if err != nil {
return
}
if response.StatusCode != 200 {
err = errorFor(request, response)
return
}
result = &DeviceHierarchy{
Device: &RemoteDevice{},
SoundZone: &RemoteSoundZone{},
Location: &RemoteLocation{},
Account: &RemoteAccount{},
}
err = json.NewDecoder(response.Body).Decode(&result)
return
}
开发者ID:DaviWei,项目名称:utils-1,代码行数:19,代码来源:client.go
示例20: DeactivatePaymentMethodAsync
func DeactivatePaymentMethodAsync(c ServiceConnector, accountId key.Key, token AccessToken) (err error) {
request, response, err := DoRequest(c, "POST", c.GetPaymentService(), fmt.Sprintf("accounts/%v/payment_method/deactivate_async", accountId.Encode()), token, nil)
if err != nil {
return
}
if response.StatusCode != 200 {
err = errorFor(request, response)
return
}
return
}
开发者ID:DaviWei,项目名称:utils-1,代码行数:12,代码来源:client.go
注:本文中的github.com/soundtrackyourbrand/utils/key.Key类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论